[Bug c++/35708] jump to label enters catch block
-- pinskia at gcc dot gnu dot org changed: What|Removed |Added Target Milestone|--- |4.3.1 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35708
[Bug c++/35708] jump to label enters catch block
--- Comment #8 from jason at gcc dot gnu dot org 2008-04-09 16:16 --- Subject: Bug 35708 Author: jason Date: Wed Apr 9 16:15:53 2008 New Revision: 134146 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=134146 Log: PR c++/35708 * semantics.c (finish_compound_literal): Return a TARGET_EXPR, not a pushed variable. Added: trunk/gcc/testsuite/g++.dg/ext/complit9.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/semantics.c trunk/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35708
[Bug c++/35708] jump to label enters catch block
--- Comment #9 from jason at gcc dot gnu dot org 2008-04-09 19:58 --- Subject: Bug 35708 Author: jason Date: Wed Apr 9 19:57:19 2008 New Revision: 134151 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=134151 Log: PR c++/35708 * semantics.c (finish_compound_literal): Return a TARGET_EXPR, not a pushed variable. Added: branches/gcc-4_3-branch/gcc/testsuite/g++.dg/ext/complit9.C - copied unchanged from r134146, trunk/gcc/testsuite/g++.dg/ext/complit9.C Modified: branches/gcc-4_3-branch/gcc/cp/ChangeLog branches/gcc-4_3-branch/gcc/cp/semantics.c branches/gcc-4_3-branch/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35708
[Bug c++/35708] jump to label enters catch block
--- Comment #10 from jason at gcc dot gnu dot org 2008-04-09 20:10 --- Fixed for 4.3.1 and 4.4.0. Patch seems risky for 4.2 at this point. -- jason at gcc dot gnu dot org changed: What|Removed |Added Known to work|4.1.3 |4.1.3 4.3.1 4.4.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35708
[Bug c++/35708] jump to label enters catch block
--- Comment #5 from rguenth at gcc dot gnu dot org 2008-03-29 10:52 --- Here's a shorter testcase: struct object { int one_o; int allocstamp; }; int pgci_pointable (object obj); void foo(void); int main (int argc, char *argv[]) { if (pgci_pointable((object){7,100})) { bad_rehash_size: foo(); } goto bad_rehash_size; } If you look at the original IL as coming from the FE you see { cleanup_point struct object D.1681 = {.one_o=7, .allocstamp=100};; Unknown tree: if_stmt cleanup_point pgci_pointable (D.1681) != 0 bad_rehash_size:; cleanup_point Unknown tree: expr_stmt foo () ; ; } goto bad_rehash_size; which is gimplified to { { struct objectD.1670 D.1681; D.1681.one_oD.1672 = 7; D.1681.allocstampD.1673 = 100; D.1699 = pgci_pointable (D.1681); retval.0D.1698 = D.1699 != 0; if (retval.0D.1698) { bad_rehash_sizeD.1697:; foo (); } else { } } goto bad_rehash_sizeD.1697; } at which point the goto enters a scope with local objects constructed before the jump target. Thus the FE generates a new scope around the if statement where the temporary object is bound to and somehow this is a of type sk_catch (that there is no checking whether something can throw inside the block may be a problem). With gcc 4.1 where the testcase is accepted we gimplify to int main(int, char**) (argc, argv) { boolD.1451 retval.0D.1759; struct objectD.1732 D.1760; intD.2 D.1761; intD.2 D.1762; D.1760.one_oD.1734 = 7; D.1760.allocstampD.1735 = 100; D.1761 = pgci_pointable (D.1760); retval.0D.1759 = D.1761 != 0; if (retval.0D.1759) { bad_rehash_sizeD.1758:; foo (); } else { } goto bad_rehash_sizeD.1758; not creating this extra scope. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added Keywords||rejects-valid Known to fail||4.2.3 4.3.0 Known to work||4.1.3 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35708
[Bug c++/35708] jump to label enters catch block
--- Comment #6 from rguenth at gcc dot gnu dot org 2008-03-29 10:56 --- Jason, can you have a look here? -- rguenth at gcc dot gnu dot org changed: What|Removed |Added CC||jason at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35708
[Bug c++/35708] jump to label enters catch block
-- jason at gcc dot gnu dot org changed: What|Removed |Added AssignedTo|unassigned at gcc dot gnu |jason at gcc dot gnu dot org |dot org | Status|UNCONFIRMED |ASSIGNED Ever Confirmed|0 |1 Last reconfirmed|-00-00 00:00:00 |2008-03-29 15:13:00 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35708
[Bug c++/35708] jump to label enters catch block
--- Comment #7 from jason at gcc dot gnu dot org 2008-03-29 15:19 --- The bug is that the temporary object created by the C99 compound literal syntax doesn't have proper C++ temporary lifetime; the compiler treats it as living until the end of the block, so the goto seems to be skipping its initialization. The compiler talks about a catch block because it assumes that the only artificial decl a goto could jump into is the one for the catch parameter. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35708
[Bug c++/35708] jump to label enters catch block
--- Comment #3 from bruno at clisp dot org 2008-03-28 22:46 --- you are entering a scope that has objects constructed. Can you point out the sections in the ISO C++ standard that say that an 'if' statement can create the scope for some objects? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35708
[Bug c++/35708] jump to label enters catch block
--- Comment #4 from bruno at clisp dot org 2008-03-28 22:48 --- The bug also occurs with g++ 4.3.0. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35708
[Bug c++/35708] jump to label enters catch block
--- Comment #1 from rguenth at gcc dot gnu dot org 2008-03-26 20:39 --- I think this is invalid, you are entering a scope that has objects constructed. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35708
[Bug c++/35708] jump to label enters catch block
--- Comment #2 from sds at gnu dot org 2008-03-26 20:44 --- so? the objects are created, used and discarded on the fly. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35708