[EMAIL PROTECTED]:/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);
}

[EMAIL PROTECTED]:/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.

-- 
           Summary: Segfault on const initializer with bogus pointer
                    arithmetics
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: falk at debian dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: alphaev68-unknown-linux-gnu
  GCC host triplet: alphaev68-unknown-linux-gnu
GCC target triplet: alphaev68-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23180

Reply via email to