-fno-strict-aliasing in CWARNFLAGS?
Soeren Sandmann
sandmann at daimi.au.dk
Wed Feb 3 10:55:22 PST 2010
Dan Nicholson <dbn.lists at gmail.com> writes:
> Here's one link:
>
> http://lkml.org/lkml/2003/2/26/158
>
> > Traditionally, -fno-strict-aliasing was definitely necessary for the X
> > server and/or some drivers to work correctly.
>
> I know in mesa it's been required. Here are two bugs fixed/worked
> around by -fno-strict-aliasing.
>
> https://bugs.freedesktop.org/show_bug.cgi?id=6046
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=394311
I recently turned it on in pixman because completely reasonable code
like this:
void
pixman_contract (uint32_t * dst,
const uint64_t *src,
int width)
{
int i;
/* Start at the beginning so that we can do the contraction in
* place when src == dst
*/
for (i = 0; i < width; i++)
{
const uint8_t a = src[i] >> 56,
r = src[i] >> 40,
g = src[i] >> 24,
b = src[i] >> 8;
dst[i] = a << 24 | r << 16 | g << 8 | b;
}
}
is actually illegal under the C aliasing rules, and GCC can and will
break it unless you use -fno-strict-aliasing. I don't think any other
compiler makes use of type based aliasing, perhaps because they
rightly - consider the standard broken.
Soren
More information about the xorg-devel
mailing list