User account creation filtered due to spam.

Bug 21788 - [x86_64] Wrong Code When Taking Address of Argument
Summary: [x86_64] Wrong Code When Taking Address of Argument
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.0.0
: P2 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-27 18:19 UTC by Evandro Menezes
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Test-case. (9.24 KB, application/x-bzip2)
2005-05-27 18:21 UTC, Evandro Menezes
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Evandro Menezes 2005-05-27 18:19:02 UTC
Using -O2 or greater, when taking the address of an input argument results in
the wrong code.  For example:

int foo (double d)
{
  int *p = (int *) &d;

  return (*p);
}

With -O2 results in:

foo:
	movq	-8(%rsp), %eax
	ret

With -O1 results in:

foo:
	movsd	%xmm0, -8(%rsp)
	movq	-8(%rsp), %eax
	ret
Comment 1 Evandro Menezes 2005-05-27 18:21:14 UTC
Created attachment 8982 [details]
Test-case.

If compiled for x86_64 with -O2 or greater, results in bogus code.
Comment 2 Andrew Pinski 2005-05-27 18:23:26 UTC
You are violating C aliasing rules, does -fno-strict-aliasing help?
Comment 3 Andrew Pinski 2005-05-27 18:34:43 UTC
You are violating C aliasing rules.
Comment 4 Evandro Menezes 2005-05-27 18:39:16 UTC
(In reply to comment #2)
The wonders of -Wall...

Yes, -fno-strict-aliasing does help.
Comment 5 Andrew Pinski 2005-06-05 09:22:51 UTC
Reopening to ...
Comment 6 Andrew Pinski 2005-06-05 09:23:10 UTC
Mark as a dup of bug 21920.

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