[Bug c/32531] New: erroneous enum comparison results

2007-06-27 Thread entrophage at gmail dot com
$ gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic
--host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20070502 (Red Hat 4.1.2-12)

$ uname -a
Linux localhost.localdomain 2.6.21-1.3228.fc7 #1 SMP Tue Jun 12 15:37:31 EDT
2007 i686 i686 i386 GNU/Linux

the following code:

#include 


enum X
{
A = 3,
B = 1,
C,
D,
E
};


int main()
{
printf("%d;\n", B == A);
printf("%d;\n", C == A);
printf("%d;\n", D == A);
printf("%d;\n", E == A);

return 0;
}

compiled with:
$ gcc -Wall -Wextra -ansi -pedantic -save-temps -o foo foo.c

gives as output:
$ ./foo
0;
0;
1;
0;


-- 
   Summary: erroneous enum comparison results
   Product: gcc
   Version: 4.1.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: entrophage at gmail dot com
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i386-redhat-linux


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



[Bug c/32531] erroneous enum comparison results

2007-06-27 Thread entrophage at gmail dot com


--- Comment #1 from entrophage at gmail dot com  2007-06-28 01:49 ---
Created an attachment (id=13799)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13799&action=view)
source file to reproduce the bug

compile with:
$ gcc -Wall -Wextra -ansi -pedantic -save-temps -o foo foo.c


-- 


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



[Bug c/32531] erroneous enum comparison results

2007-06-27 Thread entrophage at gmail dot com


--- Comment #2 from entrophage at gmail dot com  2007-06-28 01:50 ---
Created an attachment (id=13800)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13800&action=view)
preprocessor output of the source file that reproduces the bug

generated with:
$ gcc -Wall -Wextra -ansi -pedantic -save-temps -o foo foo.c


-- 


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



[Bug c/32531] erroneous enum comparison results

2007-06-27 Thread entrophage at gmail dot com


--- Comment #3 from entrophage at gmail dot com  2007-06-28 01:53 ---
valgrind of the resulting binary shows interesting output:

$ valgrind ./foo
==5107== Memcheck, a memory error detector.
==5107== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==5107== Using LibVEX rev 1732, a library for dynamic binary translation.
==5107== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==5107== Using valgrind-3.2.3, a dynamic binary instrumentation framework.
==5107== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==5107== For more details, rerun with: -v
==5107== 
==5107== Conditional jump or move depends on uninitialised value(s)
==5107==at 0x4A19FBDB: _dl_relocate_object (in /lib/ld-2.6.so)
==5107==by 0x4A1988D8: dl_main (in /lib/ld-2.6.so)
==5107==by 0x4A1A8F6A: _dl_sysdep_start (in /lib/ld-2.6.so)
==5107==by 0x4A1962B7: _dl_start (in /lib/ld-2.6.so)
==5107==by 0x4A195816: (within /lib/ld-2.6.so)
==5107== 
==5107== Conditional jump or move depends on uninitialised value(s)
==5107==at 0x4A19FBE3: _dl_relocate_object (in /lib/ld-2.6.so)
==5107==by 0x4A1988D8: dl_main (in /lib/ld-2.6.so)
==5107==by 0x4A1A8F6A: _dl_sysdep_start (in /lib/ld-2.6.so)
==5107==by 0x4A1962B7: _dl_start (in /lib/ld-2.6.so)
==5107==by 0x4A195816: (within /lib/ld-2.6.so)
==5107== 
==5107== Conditional jump or move depends on uninitialised value(s)
==5107==at 0x4A19FD25: _dl_relocate_object (in /lib/ld-2.6.so)
==5107==by 0x4A1988D8: dl_main (in /lib/ld-2.6.so)
==5107==by 0x4A1A8F6A: _dl_sysdep_start (in /lib/ld-2.6.so)
==5107==by 0x4A1962B7: _dl_start (in /lib/ld-2.6.so)
==5107==by 0x4A195816: (within /lib/ld-2.6.so)
==5107== 
==5107== Conditional jump or move depends on uninitialised value(s)
==5107==at 0x4A1A001B: _dl_relocate_object (in /lib/ld-2.6.so)
==5107==by 0x4A1988D8: dl_main (in /lib/ld-2.6.so)
==5107==by 0x4A1A8F6A: _dl_sysdep_start (in /lib/ld-2.6.so)
==5107==by 0x4A1962B7: _dl_start (in /lib/ld-2.6.so)
==5107==by 0x4A195816: (within /lib/ld-2.6.so)
==5107== 
==5107== Conditional jump or move depends on uninitialised value(s)
==5107==at 0x4A1A04F0: _dl_relocate_object (in /lib/ld-2.6.so)
==5107==by 0x4A1988D8: dl_main (in /lib/ld-2.6.so)
==5107==by 0x4A1A8F6A: _dl_sysdep_start (in /lib/ld-2.6.so)
==5107==by 0x4A1962B7: _dl_start (in /lib/ld-2.6.so)
==5107==by 0x4A195816: (within /lib/ld-2.6.so)
==5107== 
==5107== Conditional jump or move depends on uninitialised value(s)
==5107==at 0x4A19FBDB: _dl_relocate_object (in /lib/ld-2.6.so)
==5107==by 0x4A198A84: dl_main (in /lib/ld-2.6.so)
==5107==by 0x4A1A8F6A: _dl_sysdep_start (in /lib/ld-2.6.so)
==5107==by 0x4A1962B7: _dl_start (in /lib/ld-2.6.so)
==5107==by 0x4A195816: (within /lib/ld-2.6.so)
==5107== 
==5107== Conditional jump or move depends on uninitialised value(s)
==5107==at 0x4A19FBE3: _dl_relocate_object (in /lib/ld-2.6.so)
==5107==by 0x4A198A84: dl_main (in /lib/ld-2.6.so)
==5107==by 0x4A1A8F6A: _dl_sysdep_start (in /lib/ld-2.6.so)
==5107==by 0x4A1962B7: _dl_start (in /lib/ld-2.6.so)
==5107==by 0x4A195816: (within /lib/ld-2.6.so)
==5107== 
==5107== Conditional jump or move depends on uninitialised value(s)
==5107==at 0x4A19FD25: _dl_relocate_object (in /lib/ld-2.6.so)
==5107==by 0x4A198A84: dl_main (in /lib/ld-2.6.so)
==5107==by 0x4A1A8F6A: _dl_sysdep_start (in /lib/ld-2.6.so)
==5107==by 0x4A1962B7: _dl_start (in /lib/ld-2.6.so)
==5107==by 0x4A195816: (within /lib/ld-2.6.so)
0;
0;
1;
0;
==5107== 
==5107== ERROR SUMMARY: 12 errors from 8 contexts (suppressed: 0 from 0)
==5107== malloc/free: in use at exit: 0 bytes in 0 blocks.
==5107== malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
==5107== For counts of detected errors, rerun with: -v
==5107== All heap blocks were freed -- no leaks are possible.


-- 


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



[Bug c/32531] erroneous enum comparison results

2007-06-27 Thread entrophage at gmail dot com


--- Comment #4 from entrophage at gmail dot com  2007-06-28 01:58 ---
(In reply to comment #3)
> valgrind of the resulting binary shows interesting output:

this is irrelevant since binary compiled from the following trivial source file
gives the same valgrind errors.

int main()
{
return 0;
}


-- 


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