Bug#496965: g++-4.3-multilib: Bad code generation for enum switch -m32
Package: g++-4.3-multilib
Version: 4.3.1-9
Severity: important
g++ generates bad code for this program. It works with fine in 64-bit and
with older versions of gcc. I chose severity important because it is a silent
bad code generation, and it was working fine with previous versions of
gcc (feel free to downgrade it though)
#include <stdlib.h>
struct MyTypes {
enum Type {
NOVALUE = 1,
VALUE = 30,
VALUE2 = 31,
VALUE3 = -3
};
static bool isValue(MyTypes::Type value);
};
bool MyTypes::isValue(MyTypes::Type value)
{
switch (value) {
case MyTypes::VALUE:
case MyTypes::VALUE2:
case MyTypes::VALUE3: {
return true;
}
default: {
return false;
}
}
}
int main(int argc, char *argv[])
{
if (true == MyTypes::isValue(MyTypes::Type(32))) {
abort();
}
return 0;
}
guillaum@canard:~$ g++ -m32 -Wall -o e enumtest.cpp
guillaum@canard:~$ ./e
Aborted
guillaum@canard:~$ g++ -Wall -o e enumtest.cpp
guillaum@canard:~$ ./e
guillaum@canard:~$ g++-4.2 -m32 -Wall -o e enumtest.cpp
guillaum@canard:~$ ./e
guillaum@canard:~$ g++-4.1 -m32 -Wall -o e enumtest.cpp
guillaum@canard:~$ ./e
It works with -O2 though (not -O1):
guillaum@canard:~$ g++ -O2 -m32 -Wall -o e enumtest.cpp
guillaum@canard:~$ ./e
-- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.26-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.ISO-8859-15, LC_CTYPE=en_US.ISO-8859-15
(charmap=ISO-8859-15)
Shell: /bin/sh linked to /bin/bash
Versions of packages g++-4.3-multilib depends on:
ii g++-4.3 4.3.1-9 The GNU C++ compiler
ii gcc-4.3-base 4.3.1-9 The GNU Compiler Collection (base
ii gcc-4.3-multilib 4.3.1-9 The GNU C compiler
(multilib files
ii lib32stdc++6 4.3.1-9 The GNU Standard C++
Library v3 (3
g++-4.3-multilib recommends no packages.
Versions of packages g++-4.3-multilib suggests:
ii lib32stdc++6-4.3-dbg 4.3.1-9 The GNU Standard C++
Library v3 (d
-- no debconf information
--
Guillaume Morin <guillaume@morinfr.org>
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Reply to: