Closed iphydf closed 6 months ago
int *a(void) { int *a = 0; if (a == NULL) { return NULL; } return a; }
The error happens because NULL is not defined in the if condition.
NULL
if
Stack trace:
#14 0.746 Program received signal SIGSEGV, Segmentation fault. #14 0.746 constant_value_is_valid (a=0x68) at expressions.c:70 #14 0.746 70 return a->type != TYPE_NOT_CONSTANT && #14 0.746 #0 constant_value_is_valid (a=0x68) at expressions.c:70 #14 0.746 #1 0x0000000000428150 in selection_statement (ctx=ctx@entry=0x7ffe95185010) #14 0.746 at parser.c:6040 #14 0.746 #2 0x0000000000428348 in primary_block (ctx=0x7ffe95185010) at parser.c:5434 #14 0.746 #3 0x00000000004284ed in unlabeled_statement (ctx=0x7ffe95185010) #14 0.746 at parser.c:5530 #14 0.746 #4 0x0000000000428e65 in block_item (ctx=ctx@entry=0x7ffe95185010) #14 0.746 at parser.c:5910 #14 0.747 #5 0x0000000000428f40 in block_item_list (ctx=ctx@entry=0x7ffe95185010, #14 0.747 error=error@entry=0x7ffe95184b3f) at parser.c:5808 #14 0.747 #6 0x000000000042906d in compound_statement (ctx=ctx@entry=0x7ffe95185010) #14 0.747 at parser.c:5708 #14 0.747 #7 0x0000000000429375 in function_body (ctx=0x7ffe95185010) at parser.c:6443 #14 0.747 #8 function_definition_or_declaration (ctx=ctx@entry=0x7ffe95185010) #14 0.747 at parser.c:2126 #14 0.747 #9 0x0000000000429631 in external_declaration (ctx=0x7ffe95185010) #14 0.747 at parser.c:6431 #14 0.747 #10 translation_unit (ctx=ctx@entry=0x7ffe95185010, #14 0.747 berror=berror@entry=0x7ffe95184c9f) at parser.c:6412 #14 0.747 #11 0x0000000000429744 in parse (ctx=ctx@entry=0x7ffe95185010, #14 0.747 list=list@entry=0x7ffe95184d70, berror=berror@entry=0x7ffe95184d5f) #14 0.747 at parser.c:6511 #14 0.748 #12 0x0000000000429e3f in compile_one_file ( #14 0.748 file_name=file_name@entry=0x7ffe95186230 "/work/c-toxcore/toxcore/test.c", #14 0.748 options=options@entry=0x7ffe95185650, #14 0.748 out_file_name=out_file_name@entry=0x7ffe95185a30 "/work/c-toxcore/toxcore/out/test.c", argc=argc@entry=8, argv=argv@entry=0x7ffe951864f8, #14 0.748 report=report@entry=0x7ffe95186470) at parser.c:6798 #14 0.748 #13 0x000000000042a32a in compile (argc=argc@entry=8, #14 0.748 argv=argv@entry=0x7ffe951864f8, report=report@entry=0x7ffe95186470) #14 0.748 at parser.c:7031 #14 0.748 #14 0x000000000040109b in main (argc=8, argv=0x7ffe951864f8) at main.c:59
this also has being fixed in previous commits
#define X #if X #endif
The error happens because
NULL
is not defined in theif
condition.Stack trace: