This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
strict aliasing issue
- From: Stuart Hastings <stuart at apple dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 18 Aug 2006 14:00:31 -0700
- Subject: strict aliasing issue
Here's my reduced testcase:
typedef long GLint;
extern void aglChoosePixelFormat(const GLint *);
void find(const int *alistp) {
const int *blist;
int list[32];
if (alistp)
blist = alistp;
else {
list[3] = 42; /* this store disappears with -O1 -fstrict-
aliasing */
blist = list;
}
aglChoosePixelFormat((GLint*)blist);
}
(The original testcase is C++, from the FLTK project.)
If I compile this with -O1 -fstrict-aliasing, the "= 42" store
disappears. I've confirmed this on mainline PPC and x86.
I'm not a language lawyer; is this a legal program? (If the program
is legal, should I file a PR?)
stuart hastings
Apple Computer