[Bug c++/45070] Miscompiled c++ class with packed attribute on ARM with -Os optimizations (Qt 4.6.2)

2010-07-25 Thread siarhei dot siamashka at gmail dot com


--- Comment #1 from siarhei dot siamashka at gmail dot com  2010-07-25 
23:25 ---
Created an attachment (id=21308)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21308&action=view)
packed-testcase.cpp


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45070



[Bug c++/45070] Miscompiled c++ class with packed attribute on ARM with -Os optimizations (Qt 4.6.2)

2010-07-26 Thread mikpe at it dot uu dot se


--- Comment #2 from mikpe at it dot uu dot se  2010-07-26 08:49 ---
With -Os on armv5tel I see a random number repeated 16 times, with -O2 I see
the expected output.  gcc-4.4 and gcc-4.5 are affected.  (Can't test 4.6 or 4.3
right now.)


-- 

mikpe at it dot uu dot se changed:

   What|Removed |Added

 CC||mikpe at it dot uu dot se


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45070



[Bug c++/45070] Miscompiled c++ class with packed attribute on ARM with -Os optimizations (Qt 4.6.2)

2010-07-26 Thread mikpe at it dot uu dot se


--- Comment #3 from mikpe at it dot uu dot se  2010-07-26 09:33 ---
Created an attachment (id=21312)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21312&action=view)
reduced test case in C

You don't need C++ to trigger the bug.  Proper C with a function that may
recurse before returning a packed struct suffices.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45070



[Bug c++/45070] Miscompiled c++ class with packed attribute on ARM with -Os optimizations (Qt 4.6.2)

2010-07-28 Thread siarhei dot siamashka at gmail dot com


--- Comment #4 from siarhei dot siamashka at gmail dot com  2010-07-28 
07:16 ---
Could not reproduce the problem with gcc 4.3.5

Disassembly of pr45070.o:

000c :
   c:   e92d401fpush{r0, r1, r2, r3, r4, lr}
  10:   e89cldm r0, {r2, r3}
  14:   e1a04000mov r4, r0
  18:   e1520003cmp r2, r3
  1c:   b3a03000movlt   r3, #0
  20:   ba14blt 78 
  24:   e5903008ldr r3, [r0, #8]
  28:   e353cmp r3, #0
  2c:   0a0ebeq 6c 
  30:   e3a03000mov r3, #0
  34:   e5803008str r3, [r0, #8]
  38:   e284add r0, r0, #4
  3c:   ebefbl  0 
  40:   e1a4mov r0, r4
  44:   ebf0bl  c 
  48:   e1a00800lsl r0, r0, #16
  4c:   e1a00840asr r0, r0, #16
  50:   e5cdstrbr0, [sp]
  54:   e1a00420lsr r0, r0, #8
  58:   e5cd0001strbr0, [sp, #1]
  5c:   e1dd30b0ldrhr3, [sp]
  60:   e1cd30bcstrhr3, [sp, #12]
  64:   e1dd30bcldrhr3, [sp, #12]
  68:   ea02b   78 
  6c:   e3a03001mov r3, #1
  70:   e5803008str r3, [r0, #8]
  74:   e59f3010ldr r3, [pc, #16]   ; 8c 
  78:   e1cd30bcstrhr3, [sp, #12]
  7c:   e5dd300cldrbr3, [sp, #12]
  80:   e5dd000dldrbr0, [sp, #13]
  84:   e1830400orr r0, r3, r0, lsl #8
  88:   e8bd801fpop {r0, r1, r2, r3, r4, pc}

^^^ POP instruction just overwrites return value in r0 register here

  8c:   .word   0x

Looks like the function gets treated as if it were returning 'void'.


-- 

siarhei dot siamashka at gmail dot com changed:

   What|Removed |Added

   Keywords||wrong-code
  Known to fail||4.5.0
  Known to work||4.3.5


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45070



[Bug c++/45070] Miscompiled c++ class with packed attribute on ARM with -Os optimizations (Qt 4.6.2)

2010-07-28 Thread siarhei dot siamashka at gmail dot com


--- Comment #5 from siarhei dot siamashka at gmail dot com  2010-07-28 
07:18 ---
The disassembly chunk from the comment above was from gcc 4.5.0, using '-Os
-match=armv5te' options.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45070