Gentoo Archives: gentoo-amd64

From: Nikos Chantziaras <realnc@×××××.de>
To: gentoo-amd64@l.g.o
Subject: [gentoo-amd64] Re: GCC-4.5.2 Has Serious Problems
Date: Thu, 30 Jun 2011 23:45:33
Message-Id: iuj1o7$o6s$2@dough.gmane.org
In Reply to: [gentoo-amd64] Re: GCC-4.5.2 Has Serious Problems by Nikos Chantziaras
On 07/01/2011 02:35 AM, Nikos Chantziaras wrote:
> On 07/01/2011 12:45 AM, Frank Peters wrote: >> Hello, >> >> After banging my head for a while over some strange results, I began >> to suspect GCC-4.5.2, the latest version in portage, was creating >> faulty code. >> >> It seems to a correct suspicion. >> [...] >> int n; >> double x; >> unsigned long int arg; >> unsigned long int *px = (unsigned long int*)&x; > > Your code is buggy, because you're breaking C's aliasing rules. You are > not allowed to use a different pointer type to dereference a variable of > a different type. Doing so results in undefined behavior.
And here you can read more thorough information about strict aliasing: http://labs.qt.nokia.com/2011/06/10/type-punning-and-strict-aliasing

Replies

Subject Author
Re: [gentoo-amd64] Re: GCC-4.5.2 Has Serious Problems Frank Peters <frank.peters@×××××××.net>
Re: [gentoo-amd64] Re: GCC-4.5.2 Has Serious Problems Frank Peters <frank.peters@×××××××.net>
Re: [gentoo-amd64] Re: GCC-4.5.2 Has Serious Problems Frank Peters <frank.peters@×××××××.net>