Commit 68a28288 by Josh Conner Committed by Josh Conner

re PR c++/23180 (Segfault on const initializer with bogus pointer arithmetics)

        PR c++/23180
        * g++.dg/init/struct2.C: New test.
        * g++.dg/init/struct3.C: New test.

From-SVN: r104254
parent bb9baf1c
2005-09-13 Josh Conner <jconner@apple.com>
PR c++/23180
* g++.dg/init/struct2.C: New test.
* g++.dg/init/struct3.C: New test.
2005-09-13 Janis Johnson <janis187@us.ibm.com> 2005-09-13 Janis Johnson <janis187@us.ibm.com>
* gcc.dg/pr15784-4.c, gcc.dg/pr20130-1.c, gcc.dg/ucnid-6.c: * gcc.dg/pr15784-4.c, gcc.dg/pr20130-1.c, gcc.dg/ucnid-6.c:
/* PR c++/23180. */
/* Initialize a local structure with an expression that attempts to use
pointer arithmetic to calculate another structure field offset. */
void saveLoadEntries(const void *);
void saveOrLoad() {
struct Track {
char soundName[15];
};
struct SaveLoadEntry {
int offs;
int type;
int size;
};
SaveLoadEntry trackEntries = {
((long) (&((Track *) 42)->soundName[0])) - 42,
0, 1
};
saveLoadEntries(&trackEntries);
}
/* PR c++/23180. */
/* Initialize a global variable with an expression that attempts to use
pointer arithmetic to calculate a structure field offset. */
struct Track {
char soundName[15];
};
struct SaveLoadEntry {
int offs;
int type;
int size;
};
int foobar = ((long) (& ((Track *) 42)->soundName[0])) - 42;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment