public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/27241]  New: Bad code reordering when using an enum as a bitfield
@ 2006-04-21 23:02 danfuzz at milk dot com
  2006-04-21 23:04 ` [Bug c++/27241] " danfuzz at milk dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: danfuzz at milk dot com @ 2006-04-21 23:02 UTC (permalink / raw)
  To: gcc-bugs

I have an example in which it looks like code is reordered improperly. The bug
seems to be triggered by using an enumerated type in a bitfield. I found the
bug compiling for arm-elf, but I have reports that it fails in a similar way
compiling for x86 (Linux).

Here's the compile command I used and its output:

$ g++ -save-temps -v -march=armv5te -fpic -g -O2 -S shorty.cpp

Reading specs from /usr/local/armdev-051213/lib/gcc/arm-elf/3.4.5/specs
Configured with: ../gcc-3.4.5/configure --prefix=/usr/local/armdev-051213
--target=arm-elf --enable-languages=c,c++ --enable-threads --disable-nls
--enable-multilib --with-float=soft --without-fp
Thread model: single
gcc version 3.4.5
 /usr/local/armdev-051213/libexec/gcc/arm-elf/3.4.5/cc1plus -E -quiet -v
-iprefix /usr/local/armdev-051213/arm-elf/bin/../lib/gcc/arm-elf/3.4.5/
-D__ARM_ARCH_5TE__ -D__USES_INITFINI__ shorty.cpp -march=armv5te -msoft-float
-fpic -fworking-directory -O2 -o shorty.ii
ignoring nonexistent directory
"/usr/local/armdev-051213/arm-elf/bin/../lib/gcc/arm-elf/3.4.5/../../../../include/c++/3.4.5"
ignoring nonexistent directory
"/usr/local/armdev-051213/arm-elf/bin/../lib/gcc/arm-elf/3.4.5/../../../../include/c++/3.4.5/arm-elf"
ignoring nonexistent directory
"/usr/local/armdev-051213/arm-elf/bin/../lib/gcc/arm-elf/3.4.5/../../../../include/c++/3.4.5/backward"
ignoring nonexistent directory
"/usr/local/armdev-051213/arm-elf/bin/../lib/gcc/arm-elf/3.4.5/include"
ignoring nonexistent directory
"/usr/local/armdev-051213/arm-elf/bin/../lib/gcc/arm-elf/3.4.5/../../../../arm-elf/sys-include"
ignoring nonexistent directory
"/usr/local/armdev-051213/arm-elf/bin/../lib/gcc/arm-elf/3.4.5/../../../../arm-elf/include"
ignoring nonexistent directory
"/usr/local/armdev-051213/lib/gcc/arm-elf/3.4.5/../../../../include/c++/3.4.5"
ignoring nonexistent directory
"/usr/local/armdev-051213/lib/gcc/arm-elf/3.4.5/../../../../include/c++/3.4.5/arm-elf"
ignoring nonexistent directory
"/usr/local/armdev-051213/lib/gcc/arm-elf/3.4.5/../../../../include/c++/3.4.5/backward"
ignoring nonexistent directory
"/usr/local/armdev-051213/lib/gcc/arm-elf/3.4.5/../../../../arm-elf/sys-include"
ignoring nonexistent directory
"/usr/local/armdev-051213/lib/gcc/arm-elf/3.4.5/../../../../arm-elf/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/armdev-051213/lib/gcc/arm-elf/3.4.5/include
End of search list.
 /usr/local/armdev-051213/libexec/gcc/arm-elf/3.4.5/cc1plus -fpreprocessed
shorty.ii -quiet -dumpbase shorty.cpp -march=armv5te -msoft-float -auxbase
shorty -g -O2 -version -fpic -o shorty.s
GNU C++ version 3.4.5 (arm-elf)
        compiled by GNU C version 4.0.1 (Apple Computer, Inc. build 5247).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096


-- 
           Summary: Bad code reordering when using an enum as a bitfield
           Product: gcc
           Version: 3.4.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: danfuzz at milk dot com
GCC target triplet: arm-elf


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/27241] Bad code reordering when using an enum as a bitfield
  2006-04-21 23:02 [Bug c++/27241] New: Bad code reordering when using an enum as a bitfield danfuzz at milk dot com
@ 2006-04-21 23:04 ` danfuzz at milk dot com
  2006-04-21 23:07 ` pinskia at gcc dot gnu dot org
  2006-04-21 23:12 ` danfuzz at milk dot com
  2 siblings, 0 replies; 4+ messages in thread
From: danfuzz at milk dot com @ 2006-04-21 23:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from danfuzz at milk dot com  2006-04-21 23:04 -------
Created an attachment (id=11315)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11315&action=view)
Source file that demonstrates the bug

Compile this file as indicated in the original bug report, and then examine the
resulting source file.


-- 


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/27241] Bad code reordering when using an enum as a bitfield
  2006-04-21 23:02 [Bug c++/27241] New: Bad code reordering when using an enum as a bitfield danfuzz at milk dot com
  2006-04-21 23:04 ` [Bug c++/27241] " danfuzz at milk dot com
@ 2006-04-21 23:07 ` pinskia at gcc dot gnu dot org
  2006-04-21 23:12 ` danfuzz at milk dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-04-21 23:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-04-21 23:06 -------
You are violating C/C++ aliasing rules:
  Length(const Length &o) { *((unsigned int *)this) = *((unsigned int *)&o); }

Use either -fno-strict-aliasing or use memcpy but even then that might not work
as this is a non-POD.

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


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/27241] Bad code reordering when using an enum as a bitfield
  2006-04-21 23:02 [Bug c++/27241] New: Bad code reordering when using an enum as a bitfield danfuzz at milk dot com
  2006-04-21 23:04 ` [Bug c++/27241] " danfuzz at milk dot com
  2006-04-21 23:07 ` pinskia at gcc dot gnu dot org
@ 2006-04-21 23:12 ` danfuzz at milk dot com
  2 siblings, 0 replies; 4+ messages in thread
From: danfuzz at milk dot com @ 2006-04-21 23:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from danfuzz at milk dot com  2006-04-21 23:11 -------
Wow, that was quick.


-- 


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-04-21 23:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-21 23:02 [Bug c++/27241] New: Bad code reordering when using an enum as a bitfield danfuzz at milk dot com
2006-04-21 23:04 ` [Bug c++/27241] " danfuzz at milk dot com
2006-04-21 23:07 ` pinskia at gcc dot gnu dot org
2006-04-21 23:12 ` danfuzz at milk dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).