Bug 28228 - Optimize error on x86/x86_64
Summary: Optimize error on x86/x86_64
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-03 02:17 UTC by Takahisa Yokota
Modified: 2006-07-03 03:36 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build: x86_64,x86_*
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 Takahisa Yokota 2006-07-03 02:17:23 UTC
test.c
-----------------------------
int
main () {
  char ba[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
  short a[4] = { 0x04, 0x05, 0x06, 0x07};

  int c = *((int *)(&a[1]));
  int d = *((int *)(&ba[1]));

  printf("%08x\n", c );
  printf("%08x\n", d );
  return 0;
}
--------------
gcc -O2
a.out

00000040
05040302
--------------
gcc -O
a.out

00060005
05040302
Comment 1 Andrew Pinski 2006-07-03 03:36:06 UTC
You violating C aliasing rules:
  int c = *((int *)(&a[1]));


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