#include <stdio.h> int main() { int* const savepos = sizeof(*savepos) ? 0 : 0; // code for the next line is left out! printf("size of thingy is %d\n", sizeof(*savepos)); } Any line of code containing sizeof(*savepos) gets stripped. If you compile and run this, nothing is printed.
/* Using built-in specs. Target: x86_64-redhat-linux-gnu Configured with: ../gcc-4.0.3/configure x86_64-redhat-linux-gnu --prefix=/pixar/d2/sets/t\ ools-03 --exec-prefix=/pixar/d2/sets/tools-03 --bindir=/pixar/d2/sets/tools-03/bin --sbin\ dir=/pixar/d2/sets/tools-03/sbin --sysconfdir=/pixar/d2/sets/tools-03/etc --datadir=/pixa\ r/d2/sets/tools-03/share --includedir=/pixar/d2/sets/tools-03/include --libdir=/pixar/d2/\ sets/tools-03/lib --libexecdir=/pixar/d2/sets/tools-03/libexec --localstatedir=/pixar/d2/\ sets/tools-03/var --sharedstatedir=/pixar/d2/sets/tools-03/com --mandir=/pixar/d2/sets/to\ ols-03/man --infodir=/pixar/d2/sets/tools-03/info --enable-version-specific-runtime-libs \ --enable-languages=c++,objc,f95 --enable-threads=posix --enable-shared --enable-mudflap Thread model: posix gcc version 4.0.3 Compile as: g++ bug.cpp Issue: Calll to printf left out. (Indeed, any line of code that contains sizeof(*savepos) gets tossed on the floor. I assume since sizeof() is a compile-time construct, something took this a bit too far? */
The front-end was produce an error_mark_node when no error had been produced. This works on the today's mainline but failed with "4.1.2 20060814".
It also worked in "4.1.0 20051026".
Confirmed, still broken as of today "4.1.2 20060917".
Janis, can you hunt this? The 4.1 branch doesn't print anything while 4.2 prints "size of thingy is 4". Thanks!
A regression hunt on the gcc-4_1-branch identified the following patch where the failure starts: http://gcc.gnu.org/viewcvs?view=rev&rev=111231 r111231 | mmitchel | 2006-02-18 08:37:34 +0000 (Sat, 18 Feb 2006)
Egads, that's awful.
Subject: Bug 29106 Author: mmitchel Date: Tue Nov 14 05:11:32 2006 New Revision: 118803 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118803 Log: PR c++/29106 * init.c (constant_value_1): Treat a DECL_INITIAL of error_mark_node as meaning that the variable is uninitialized, rather than erroneously initialized. PR c++/29106 * g++.dg/init/self1.C: New test. * g++.dg/other/fold1.C: Adjust error markers. * g++.dg/init/member1.C: Likewise. Added: branches/gcc-4_1-branch/gcc/testsuite/g++.dg/init/self1.C Modified: branches/gcc-4_1-branch/gcc/cp/ChangeLog branches/gcc-4_1-branch/gcc/cp/init.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog branches/gcc-4_1-branch/gcc/testsuite/g++.dg/init/member1.C branches/gcc-4_1-branch/gcc/testsuite/g++.dg/other/fold1.C
Fixed in 4.1.2.
Subject: Bug 29106 Author: mmitchel Date: Tue Nov 14 17:13:57 2006 New Revision: 118818 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118818 Log: PR c++/29106 * g++.dg/init/self1.C: New test. Added: branches/gcc-4_2-branch/gcc/testsuite/g++.dg/init/self1.C Modified: branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
Subject: Bug 29106 Author: mmitchel Date: Tue Nov 14 17:15:08 2006 New Revision: 118819 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118819 Log: PR c++/29106 * g++.dg/init/self1.C: New test. Added: trunk/gcc/testsuite/g++.dg/init/self1.C Modified: trunk/gcc/testsuite/ChangeLog
Btw, the fix ported PR28284 back to the 4.1 branch.
Subject: Bug number PR c++/29106 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-01/msg02248.html
Subject: Bug 29106 Author: reichelt Date: Sat Jan 27 19:58:38 2007 New Revision: 121238 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121238 Log: Backport: 2006-11-13 Mark Mitchell <mark@codesourcery.com> PR c++/29106 * init.c (constant_value_1): Treat a DECL_INITIAL of error_mark_node as meaning that the variable is uninitialized, rather than erroneously initialized. * g++.dg/init/self1.C: New test. * g++.dg/other/fold1.C: Adjust error markers. * g++.dg/init/member1.C: Likewise. 2006-08-27 Simon Martin <simartin@users.sourceforge.net> PR c++/28284 * pt.c (fold_non_dependent_expr): Make sure expr is not dereferenced if it is NULL. * g++.dg/template/pr28284.C: New test. Added: branches/gcc-4_0-branch/gcc/testsuite/g++.dg/init/self1.C branches/gcc-4_0-branch/gcc/testsuite/g++.dg/template/pr28284.C Modified: branches/gcc-4_0-branch/gcc/cp/ChangeLog branches/gcc-4_0-branch/gcc/cp/init.c branches/gcc-4_0-branch/gcc/cp/pt.c branches/gcc-4_0-branch/gcc/testsuite/ChangeLog branches/gcc-4_0-branch/gcc/testsuite/g++.dg/init/member1.C branches/gcc-4_0-branch/gcc/testsuite/g++.dg/other/fold1.C
Also fixed in GCC 4.0.4.
*** Bug 31049 has been marked as a duplicate of this bug. ***