falk@juist:/tmp% cat bug.cc void saveLoadEntries(const void *); void saveOrLoad() { struct Track { char soundName[15]; }; struct SaveLoadEntry { int offs; int type; int size; }; const SaveLoadEntry trackEntries = { ((long) (&((Track *) 42)->soundName[0])) - 42, 0, 1 }; saveLoadEntries(&trackEntries); } falk@juist:/tmp% g++ -c bug.cc bug.cc:15: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. In case anyone wonders, this comes from: // * To work around a warning in GCC 3.2 (and 3.1 ?) regarding non-POD types[...] #define OFFS(type,item) (((long)(&((type*)42)->type::item))-42) This is of course invalid, but it'd be nice if it did what those folks wanted.
Confirmed, a regression from 4.0.0.
Here is the backtrace: #1 0x08423014 in expand_binop (mode=SImode, binoptab=0xb7cb4600, op0=0xb7cac360, op1=0xb7cac0c0, target=0x0, unsignedp=1, methods=OPTAB_LIB_WIDEN) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/optabs.c:1028 #2 0x082f9625 in expand_expr_addr_expr_1 (exp=Variable "exp" is not available. ) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/expr.c:6310 #3 0x082ec524 in expand_expr_real_1 (exp=0xb7d2b4c0, target=0x0, tmode=SImode, modifier=Variable "modifier" is not available. ) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/expr.c:6349 #4 0x082f5cbe in expand_expr_real (exp=0xb7d2b4c0, target=0x0, tmode=VOIDmode, modifier=EXPAND_INITIALIZER, alt_rtl=0x0) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/expr.c:6462 #5 0x084b6180 in output_constant (exp=0xb7d2b4c0, size=4, align=32) at expr.h:492 #6 0x084b5308 in output_constructor (exp=0xb7d4f900, size=12, align=32)
Subject: Bug 23180 CVSROOT: /cvs/gcc Module name: gcc Changes by: jconner@gcc.gnu.org 2005-09-09 01:37:31 Modified files: gcc : ChangeLog expr.c Log message: PR c++/23180 * expr.c (expand_expr_addr_expr_1): Don't invoke expand_simple_binop for EXPAND_INITIALIZER. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9921&r2=2.9922 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/expr.c.diff?cvsroot=gcc&r1=1.815&r2=1.816
Subject: Bug 23180 CVSROOT: /cvs/gcc Module name: gcc Changes by: jconner@gcc.gnu.org 2005-09-09 01:39:36 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/init: pr23180-1.C pr23180-2.C Log message: PR c++/23180 * g++.dg/init/pr23180-1.C: New test. * g++.dg/init/pr23180-2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6034&r2=1.6035 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/pr23180-1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/pr23180-2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed.
Subject: Bug 23180 CVSROOT: /cvs/gcc Module name: gcc Changes by: jconner@gcc.gnu.org 2005-09-14 00:25:02 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/init: struct2.C struct3.C Log message: PR c++/23180 * g++.dg/init/struct2.C: New test. * g++.dg/init/struct3.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6061&r2=1.6062 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/struct2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/struct3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1