Bug 27426 - optimization results in wrong argument passing
Summary: optimization results in wrong argument passing
Status: RESOLVED DUPLICATE of bug 21920
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.2
: P3 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-04 16:00 UTC by Pavel Uvarov
Modified: 2006-05-04 22:10 UTC (History)
60 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 Pavel Uvarov 2006-05-04 16:00:51 UTC
Expected output on little-endian machines:
DEF05678 

Real output with optimization -O2 (where ???? -- is trash):
DEF0????

Compilation command: g++ -O2 t.c

Program text:

#include <stdio.h>

typedef unsigned char uint08_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long uint64_t;

int main()
{
   uint64_t val = uint64_t(0x123456789ABCDEF0);
   uint08_t h[6];
   *(uint16_t*)h = (val >> 32) & 0xffff;
   *(uint32_t*)(h + 2) = val & 0xffffffff;
   uint32_t res = *((uint32_t *)h);
   printf ("%08X\n", res);
   return 0;
}
Comment 1 Andrew Pinski 2006-05-04 16:02:50 UTC

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