This is the mail archive of the
mailing list for the GCC project.
Re: finding strict aliasing problems
- To: gdr at codesoucery dot com (Gabriel Dos Reis)
- Subject: Re: finding strict aliasing problems
- From: Brad Lucier <lucier at math dot purdue dot edu>
- Date: Tue, 1 May 2001 17:55:04 -0500 (EST)
- Cc: mrs at windriver dot com (Mike Stump), jakub at redhat dot com, jbuck at racerx dot synopsys dot com, feeley at iro dot umontreal dot ca, gcc at gcc dot gnu dot org, lucier at math dot purdue dot edu
One thing I do *not* want to do is start a repeat of
the 1999 discussion.
So, there are some obvious aliasing problems with this code
(especially in the bignum code, where the bignum digits are
accessed either as 64-bit unsigned ints or 16-bit unsigned ints).
But is this a problem?
foo (long int x)
printf("%d %f\n", *((int *) x), *(double *) (((int *) x) + 1));
long int x = (long int) malloc (sizeof(int)+sizeof(double));
*(int *)x = 1;
*(double *) (((int *) x) + 1) = 2.0;
Here, each word of memory is accessed either as double or
int, but not both, even though to get to a valid double pointer
I need to increment the int pointer. Is this OK?
Compiled with yesterday's 3.1 with -Wall -W without any warnings.