https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82051
Bug ID: 82051 Summary: [mips]mips emit different results when compiling union var using -O0/-O2 Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: zwzhangwen.zhang at huawei dot com Target Milestone: --- When compiling union var using -O0/-O2, elf print different results. Command line: mips-linux-gnueabi-gcc -w -march=34kc -static ./test.c -O0/-O2 Executing results are as follows: [O0] g_121.f0=fffffce9 g_121.f1=81 g_121.f2=ce900000 g_121.f3=ce g_121.f4=ce [O2] g_121.f0=fffffce9 g_121.f1=81 g_121.f2=ce900000 g_121.f3=ce g_121.f4=fc ==> gcc-6.3.0/7.1.0/8.0.0 I have check the results with X86 compiler, the result is as expected: g_121.f0=fffffce9 g_121.f1=ce9 g_121.f2=ce9 g_121.f3=e9 g_121.f4=e9 ==> gcc-4.3.4 ccp2 pass g_121.f4 propagates 252 and I have no deep investigattion. testcase: #include <stdio.h> union U0 { signed f0 : 12; volatile long long f1; volatile int f2; const volatile unsigned char f3; unsigned char f4; }; static union U0 g_121 = {0x549E5CE9L};/* VOLATILE GLOBAL g_121 */ /* ---------------------------------------- */ int main (int argc, char* argv[]) { printf ("g_121.f0=%x\n",g_121.f0); printf ("g_121.f1=%x\n",g_121.f1); printf ("g_121.f2=%x\n",g_121.f2); printf ("g_121.f3=%x\n",g_121.f3); printf ("g_121.f4=%x\n",g_121.f4); return 0; }