User account creation filtered due to spam.

Bug 4570 - error reading bytes from double variable
Summary: error reading bytes from double variable
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.0.2
: P2 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-15 02:06 UTC by philippe_ribet
Modified: 2005-11-10 03:59 UTC (History)
52 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description philippe_ribet 2001-10-15 02:06:02 UTC
gcc-3.0.1 give good result up to -O2, bad one with -O3
gcc-3.0.2 give good result without optimization, bad with -O2
May be relative to optimization recently moved from -O3 to -O2.

main()
{
  double e=0;
  e=(double)(0.5);
  printf("e=%08x%08x\n",*((int *)(((char *)(&e)))),*((int *)(((char *)(&e))+4)));
}

Release:
gcc version 3.0.2 20010922

Environment:
Athlon processor
Comment 1 Alexandre Oliva 2001-11-25 08:45:58 UTC
State-Changed-From-To: open->closed
State-Changed-Why: Not a bug.  GCC is allowed by the aliasing rules in the C Standard to assume an int* can't possibly point to the same memory as e, that has type double.  If you depend on this behavior, use -fno-strict-aliasing, or access the storage using pointers to char, that can alias anything.
Comment 2 Alexandre Oliva 2001-11-25 16:45:59 UTC
From: aoliva@gcc.gnu.org
To: gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org,
  nobody@gcc.gnu.org, philippe_ribet@hotmail.com
Cc:  
Subject: Re: optimization/4570: error reading bytes from double variable
Date: 25 Nov 2001 16:45:59 -0000

 Synopsis: error reading bytes from double variable
 
 State-Changed-From-To: open->closed
 State-Changed-By: aoliva
 State-Changed-When: Sun Nov 25 08:45:58 2001
 State-Changed-Why:
     Not a bug.  GCC is allowed by the aliasing rules in the C Standard to assume an int* can't possibly point to the same memory as e, that has type double.  If you depend on this behavior, use -fno-strict-aliasing, or access the storage using pointers to char, that can alias anything.
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4570&database=gcc
Comment 3 Andrew Pinski 2005-11-10 03:59:32 UTC
Reopening to ...
Comment 4 Andrew Pinski 2005-11-10 03:59:46 UTC
Mark as a dup of bug 21920.

*** This bug has been marked as a duplicate of 21920 ***