Summary: | [3.4/4.0 Regression] [unit-at-a-time] initializing const data with reinterpret_cast-ed pointer-to-member function crashes | ||
---|---|---|---|
Product: | gcc | Reporter: | David Baron <dbaron> |
Component: | c++ | Assignee: | Mark Mitchell <mark> |
Status: | RESOLVED FIXED | ||
Severity: | critical | CC: | bryner, debian-gcc, gcc-bugs, gdr, hubicka, mmitchel, trentalg |
Priority: | P2 | Keywords: | patch, wrong-code |
Version: | 3.4.0 | ||
Target Milestone: | 3.4.0 | ||
Host: | i686-gnu-linux-gnu | Target: | i686-gnu-linux-gnu |
Build: | i686-gnu-linux-gnu | Known to work: | 3.3.3 3.3.4 |
Known to fail: | 3.4.0 4.0.0 | Last reconfirmed: | 2004-04-01 01:38:53 |
Attachments: | testcase |
Description
David Baron
2004-04-01 01:32:43 UTC
Created attachment 6022 [details]
testcase
Confirmed. *** Bug 14640 has been marked as a duplicate of this bug. *** Further testing shows that the bug happens the same way even if the function is not virtual, as long as reinterpret_cast (rather than static_cast) is present. (And in the non-virtual case, when -fPIC is used, the data should be in .rel.ro.data instead of .rodata -- which again works fine when static_cast is used instead of reinterpret_cast.) Why was this marked as a 3.3 regression? The bug is not present in 3.3.3. Ah, never mind. I see the comments on bug 14640 indicating that it's a regression on the 3.3 branch since 3.3.3. Because it is broken on the 3.3 branch, see the dup bug. It's also probably worth noting here what bug 14640 comment 8 says: that the regression was caused by the backport of PR10776. Retargeted at 3.4.0, since Mozilla depends on this. Richard, does this problem have to do with your optimizations to the way we emit aggregate initializers? Mine; testing patch. Subject: Bug 14804 CVSROOT: /cvs/gcc Module name: gcc Changes by: rth@gcc.gnu.org 2004-04-01 20:45:02 Modified files: gcc/cp : ChangeLog decl.c typeck2.c Added files: gcc/testsuite/g++.dg/init: static2.C Log message: PR c++/14804 * decl.c (cp_finish_decl): Preserve TREE_READONLY more often. * typeck2.c (split_nonconstant_init): Clear TREE_READONLY. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4023&r2=1.4024 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1200&r2=1.1201 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck2.c.diff?cvsroot=gcc&r1=1.155&r2=1.156 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/static2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 Subject: Bug 14804 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: rth@gcc.gnu.org 2004-04-01 20:47:27 Modified files: gcc/cp : ChangeLog decl.c typeck2.c Added files: gcc/testsuite/g++.dg/init: static2.C Log message: PR c++/14804 * decl.c (cp_finish_decl): Preserve TREE_READONLY more often. * typeck2.c (split_nonconstant_init): Clear TREE_READONLY. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.92&r2=1.3892.2.93 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1174.2.18&r2=1.1174.2.19 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.153.4.2&r2=1.153.4.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/static2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 Subject: Bug 14804 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: rth@gcc.gnu.org 2004-04-01 21:48:06 Modified files: gcc/cp : ChangeLog decl.c typeck2.c Added files: gcc/testsuite/g++.dg/init: static2.C Log message: PR c++/14804 * decl.c (cp_finish_decl): Preserve TREE_READONLY more often. * typeck2.c (split_nonconstant_init): Clear TREE_READONLY. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.264&r2=1.3076.2.265 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.80&r2=1.965.2.81 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.132.4.5&r2=1.132.4.6 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/static2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.4.1 Fixed. No, it is not. Testcase still segfaults if compiled with -funit-at-a-time. $ g++ -O3 -fno-unit-at-a-time 14804.cc $ ./a.out $ g++ -funit-at-a-time 14804.cc $ ./a.out Segmentation fault $ This is true for both 3.4.0 and 3.5.0 from 20040403. This is now only a 3.4.0/3.5.0 regression as unit-at-a-time is only in 3.4.0 and above. Jan or RTH could you look into why unit-at-a-time could cause this. I saw that GCC was putting the symbol still in read only data for unit-at-a-time. Working on a fix. Subject: Bug 14804 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2004-04-04 22:50:28 Modified files: gcc : ChangeLog varasm.c Log message: PR c++/14804 * varasm.c (initializer_constant_valid_p): Allow NOP_EXPRs to RECORD_TYPEs. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.378&r2=2.2326.2.379 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/varasm.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.405.2.1&r2=1.405.2.2 Subject: Bug 14804 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-04-04 22:51:03 Modified files: gcc : ChangeLog varasm.c Log message: PR c++/14804 * varasm.c (initializer_constant_valid_p): Allow NOP_EXPRs to RECORD_TYPEs. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.3340&r2=2.3341 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/varasm.c.diff?cvsroot=gcc&r1=1.417&r2=1.418 Fixed it harder. Subject: Bug 14804 CVSROOT: /cvs/gcc Module name: gcc Branch: hammer-3_3-branch Changes by: matz@gcc.gnu.org 2004-07-19 12:08:46 Modified files: gcc : ChangeLog.hammer varasm.c Log message: Backport (for #42522): 2004-04-04 Mark Mitchell <mark@codesourcery.com> PR c++/14804 * varasm.c (initializer_constant_valid_p): Allow NOP_EXPRs to RECORD_TYPEs. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.hammer.diff?cvsroot=gcc&only_with_tag=hammer-3_3-branch&r1=1.1.2.414&r2=1.1.2.415 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/varasm.c.diff?cvsroot=gcc&only_with_tag=hammer-3_3-branch&r1=1.318.2.18&r2=1.318.2.19 |