|
From: | Sergey Korshunoff |
Subject: | Re: [Tinycc-devel] nocode_wanted does not work |
Date: | Sun, 3 Apr 2016 15:47:25 +0300 |
> Or at least fail with an explanatoryI can not grock what is wrong (where is the error). But is starts in
> message if o() is called while nocode_wanted is set?
block.c: 5001 when ({}) is used.
antoo # gdb tcc
(gdb) set args vla_label_fix_problem.c
(gdb) b check_nocode_wanted
Breakpoint 1 at 0x806193a: file i386-gen.c, line 118.
(gdb) r
Starting program: /usr/local/bin/tcc vla_label_fix_problem.c
Breakpoint 1, check_nocode_wanted () at i386-gen.c:118
118 if (nocode_wanted)
(gdb) bt
#0 check_nocode_wanted () at i386-gen.c:118
#1 0x08061960 in o (c=184) at i386-gen.c:124
#2 0x08061dbd in load (r=0, sv=0x80742b8) at i386-gen.c:269
#3 0x08050c95 in gv (rc=1) at tccgen.c:979
#4 0x08054882 in vstore () at tccgen.c:2752
#5 0x08059b06 in init_putv (type=0xbfeb2c18, sec=0x0, c=4294967292, v=0, expr_type=2) at tccgen.c:5559
#6 0x0805a3ce in decl_initializer (type=0xbfeb2c18, sec=0x0, c=4294967292, first=1, size_only=0) at tccgen.c:5867
#7 0x0805a9f7 in decl_initializer_alloc (type=0xbfeb2c18, ad=0xbfeb2bf0, r=306, has_init=1, v=1169, scope=50)
at tccgen.c:6102
#8 0x0805b7a6 in decl0 (l=50, is_for_loop_init=0) at tccgen.c:6522
#9 0x0805b80e in decl (l=50) at tccgen.c:6541
#10 0x08058534 in label_or_decl (l=50) at tccgen.c:4919
#11 0x08058819 in block (bsym=0x0, csym=0x0, case_sym=0x0, def_sym=0x0, case_reg=0, is_expr=0) at tccgen.c:5001
#12 0x0805ade4 in gen_function (sym=0x8d931c4) at tccgen.c:6216
#13 0x0805b5a9 in decl0 (l=48, is_for_loop_init=0) at tccgen.c:6468
#14 0x0805b80e in decl (l=48) at tccgen.c:6541
#15 0x08068882 in tcc_compile (s1=0x8d86008) at libtcc.c:976
#16 0x08069374 in tcc_add_file_internal (s1=0x8d86008, filename=0x8d94241 "vla_label_fix_problem.c", flags=1, filetype=2)
at libtcc.c:1384
#17 0x08069581 in tcc_add_file (s=0x8d86008, filename=0x8d94241 "vla_label_fix_problem.c", filetype=2) at libtcc.c:1476
#18 0x0806b63a in main (argc=2, argv=0xbfeb31f4) at tcc.c:326
(gdb).
block.c: 5001
while (tok != '}') {
label_or_decl(VT_LOCAL);
if (tok != '}') {
if (is_expr)
vpop();
block(bsym, csym, case_sym, def_sym, case_reg, is_expr);
}
}2016-04-03 12:13 GMT+03:00 Edmund Grimley Evans <address@hidden>:> Hi! The following test hangs when compiled with tcc after 737f98421
> tccgen.c: Bug fix for 992cbda and 3ff77a1: set nocode_wanted.
> tests/tests2/78_vla_label.*: Add test
The change introduced at 737f98421 depends on "nocode_wanted" working.
But it doesn't work, of course. It's broken probably in lots of ways,
but in particular a "do" loop will generate code when it shouldn't. So
another instance of the same bug is demonstrated by this:
int main()
{
return sizeof( ({ do { } while (1); }), 0 );
}
(So the bug perhaps only affects statement expressions, which are not
part of standard C.)
I wonder, how feasible is it to find every place in tccgen.c where a
back-end function like gjmp might be called and ensure that it won't
be called when nocode_wanted is set? Could this be done more
systematically at a lower level? Or at least fail with an explanatory
message if o() is called while nocode_wanted is set?
Edmund
_______________________________________________
Tinycc-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
[Prev in Thread] | Current Thread | [Next in Thread] |