سؤال

I am a bit lost working with the following piece of code:

  T_TERM_LIST term_list = term_list_one($1);
  term_list = term_list_add(term_list, $3);
  T_TERM term_equality = term_app(str_make("="), term_list);  
  T_TERM_LIST term_list_2 = term_list_one(term_equality);
  $$ = term_app(str_make("not"), term_list_2); 
  printf("\n100 \n"); 

My question is regarding the last line, if I leave the printf statement it works as expected else if I remove the printf line I get a null pointer exception, I would like to understad what is ging on there.

As a matter of adding information the datatypes used are typedefs of unsigned and list of unsigned.

In addition The code is embedded into a YACC file which may explain the symbols $n in the shared piece of code code.

هل كانت مفيدة؟

المحلول

As @chux advised me I copy & paste my comment as the answer to my question. Actually it is a kind of lessons learned.

I found out that the code compiled by make clean; make is different of the code compiled by make clean; make debug which adds all the flags for debugging. The results for the former are the expected whereas the null pointer reference is obtained in the later case. So I think we can finish this question by pointing that using valgring and gdb is a good choice in order to solve the problem I posed.

Thanks a lot!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top