From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QcQnV-0007qh-2O for garchives@archives.gentoo.org; Thu, 30 Jun 2011 23:37:25 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6B8031C070; Thu, 30 Jun 2011 23:35:40 +0000 (UTC) Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by pigeon.gentoo.org (Postfix) with ESMTP id 3014D1C070 for ; Thu, 30 Jun 2011 23:35:40 +0000 (UTC) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QcQlm-0001S1-Gn for gentoo-amd64@lists.gentoo.org; Fri, 01 Jul 2011 01:35:38 +0200 Received: from athedsl-375737.home.otenet.gr ([79.131.19.183]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 01 Jul 2011 01:35:38 +0200 Received: from realnc by athedsl-375737.home.otenet.gr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 01 Jul 2011 01:35:38 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: gentoo-amd64@lists.gentoo.org From: Nikos Chantziaras Subject: [gentoo-amd64] Re: GCC-4.5.2 Has Serious Problems Date: Fri, 01 Jul 2011 02:35:55 +0300 Organization: Lucas Barks Message-ID: References: <20110630174530.9bcbcd47.frank.peters@comcast.net> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-amd64@lists.gentoo.org Reply-to: gentoo-amd64@lists.gentoo.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: athedsl-375737.home.otenet.gr User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110624 Thunderbird/3.1.11 In-Reply-To: <20110630174530.9bcbcd47.frank.peters@comcast.net> X-Archives-Salt: X-Archives-Hash: 6c6c79cc8530ae5abbc77acd679b2cd1 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