Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 15277
Product:  
Component:  
Status: RESOLVED
Resolution: DUPLICATE of bug 15069
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Joseph Heled <pepster@users.sourceforge.net>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 15277 depends on: Show dependency tree
Show dependency graph
Bug 15277 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2004-05-04 04:57
Bug in g++ 3.4.0 code genetarion.
Included below a test program, and assembly output from 3.4.0 (incorrect) and
3.3 (correct).

Thanks, Joseph

> uname -a
Linux yoda 2.4.18-18.8.0 #1 Wed Nov 13 22:52:09 EST 2002 i686 athlon i386 GNU/Linux

c++ source
==============================================================================
struct X {
  static unsigned int const bit = 0x2;

  enum Mode {
    B0 = 0x0,
      
    B1 = 0x1,

    B2 = 0x2,

    B3 = 0x3,
  };

  Mode		mode : 2;

  // return true if second bit is on
  bool	bit2(void) const { return (mode & bit) ? true : false; }
};

#include <iostream>

int
main()
{
  X x;
  x.mode =  x.B3;
  std::cout << "should be 3 1: " << x.mode << ' ' << x.bit2();
  return 0;
}

================================================================================

Run result:
  should be 3 1: 3 0

================================================================================
Compilation

> g++ -v -o i2 i2.cc
Reading specs from /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: ../gcc-3.4.0/configure --with-cpu=athlon-xp
--with-arch=athlon-xp --enable-languages=c,c++
Thread model: posix
gcc version 3.4.0
 /usr/local/libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus -quiet -v -D_GNU_SOURCE
i2.cc -quiet -dumpbase i2.cc -march=athlon-xp -auxbase i2 -version -o
/tmp/ccjQgv65.s
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory
"/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
 /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/i686-pc-linux-gnu
 /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/backward
 /usr/local/include
 /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/include
 /usr/include
End of search list.
GNU C++ version 3.4.0 (i686-pc-linux-gnu)
	compiled by GNU C version 3.4.0.
GGC heuristics: --param ggc-min-expand=45 --param ggc-min-heapsize=29906
 as -V -Qy -o /tmp/cczxH2c6.o /tmp/ccjQgv65.s
GNU assembler version 2.13.90.0.2 (i386-redhat-linux) using BFD version
2.13.90.0.2 20020802
 /usr/local/libexec/gcc/i686-pc-linux-gnu/3.4.0/collect2 --eh-frame-hdr -m
elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o i2 /usr/lib/crt1.o
/usr/lib/crti.o /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/crtbegin.o
-L/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0
-L/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../.. /tmp/cczxH2c6.o -lstdc++
-lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/crtend.o /usr/lib/crtn.o
====================================================================================

Incorrect assembly code

_ZNK1X4bit2Ev:
.LFB2:
	pushl	%ebp
.LCFI7:
	movl	%esp, %ebp
.LCFI8:
	movl	8(%ebp), %eax
	movzbl	(%eax), %eax
	andl	$3, %eax
	shrl	$31, %eax         <===================== what the ...
	leave
	ret


====================================================================================

Correct 3.3 assembly code

_ZNK1X4bit2Ev:
.LFB1477:
	pushl	%ebp
.LCFI7:
	movl	%esp, %ebp
.LCFI8:
	movl	8(%ebp), %eax
	movzbl	(%eax), %eax
	andl	$3, %eax
	shrl	%eax
	andl	$1, %eax
	popl	%ebp
	ret

------- Comment #1 From Andrew Pinski 2004-05-04 05:16 -------
This is a dup of bug 15069.

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

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug