Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-amd64
Navigation:
Lists: gentoo-amd64: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-amd64@g.o
From: Nikos Chantziaras <realnc@...>
Subject: Re: GCC-4.5.2 Has Serious Problems
Date: Fri, 01 Jul 2011 02:35:55 +0300
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.

Short answer, GCC is correct, you are wrong :-)  To compile code that 
breaks aliasing rules, always use the "-fno-strict-aliasing" option.  In 
this case:

   gcc -O2 -fno-strict-aliasing




Replies:
Re: GCC-4.5.2 Has Serious Problems
-- Nikos Chantziaras
References:
GCC-4.5.2 Has Serious Problems
-- Frank Peters
Navigation:
Lists: gentoo-amd64: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
Re: GCC-4.5.2 Has Serious Problems
Next by thread:
Re: GCC-4.5.2 Has Serious Problems
Previous by date:
Re: GCC-4.5.2 Has Serious Problems
Next by date:
Re: GCC-4.5.2 Has Serious Problems


Updated Jun 04, 2012

Summary: Archive of the gentoo-amd64 mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.