Bug 37946 - [c++0x] ICE with enum class
Summary: [c++0x] ICE with enum class
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.1
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2008-10-28 23:33 UTC by Piotr Rak
Modified: 2009-07-07 22:13 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-12-30 01:33:13


Attachments
Test case (127 bytes, text/plain)
2008-10-28 23:35 UTC, Piotr Rak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Rak 2008-10-28 23:33:08 UTC
Following (valid I believe) code causes internal compiler error:
enum class E : char
{
    e1,
    e2
};

inline E operator| (E a1, E a2)
{
    char ret = static_cast<char> (a1) 
        | static_cast<char> (a2);
    return static_cast<E>(ret);
}
 g++-4.4.0-alpha20081010 -v -c -std=c++0x enum_class_ice.cc 
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/paludis/sys-devel-gcc-4.4.0_alpha20081010/work/gcc-4.4-20081010/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.4.0-alpha20081010 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.4.0-alpha20081010 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.4.0-alpha20081010/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.4.0-alpha20081010/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --enable-cld --disable-libgcj --with-arch=i686 --enable-languages=c,c++ --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.4.0_alpha20081010'
Thread model: posix
gcc version 4.4.0-alpha20081010  (experimental) (Gentoo 4.4.0_alpha20081010) 
COLLECT_GCC_OPTIONS='-v' '-c' '-std=c++0x' '-E' '-shared-libgcc' '-mtune=generic' '-march=i686'
 /usr/libexec/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/cc1plus -E -quiet -v -D_GNU_SOURCE enum_class_ice.cc -mtune=generic -march=i686 -std=c++0x
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/include/g++-v4
 /usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/include/g++-v4/i686-pc-linux-gnu
 /usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/include/g++-v4/backward
 /usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/include
 /usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/include-fixed
 /usr/include
End of search list.
COMPILER_PATH=/usr/libexec/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/:/usr/libexec/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/:/usr/libexec/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/:/usr/lib/gcc/i686-pc-linux-gnu/:/usr/libexec/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/:/usr/libexec/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/:/usr/lib/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/../../../../i686-pc-linux-gnu/bin/
LIBRARY_PATH=/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/:/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/:/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/../../../../i686-pc-linux-gnu/lib/:/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-c' '-std=c++0x' '-E' '-shared-libgcc' '-mtune=generic' '-march=i686'
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/paludis/sys-devel-gcc-4.4.0_alpha20081010/work/gcc-4.4-20081010/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.4.0-alpha20081010 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.4.0-alpha20081010 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.4.0-alpha20081010/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.4.0-alpha20081010/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --enable-cld --disable-libgcj --with-arch=i686 --enable-languages=c,c++ --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.4.0_alpha20081010'
Thread model: posix
gcc version 4.4.0-alpha20081010  (experimental) (Gentoo 4.4.0_alpha20081010) 
COLLECT_GCC_OPTIONS='-v' '-c' '-std=c++0x' '-o' '/home/prak/.ccache/tmp.hash.sandra.23558.o' '-shared-libgcc' '-mtune=generic' '-march=i686'
 /usr/libexec/gcc/i686-pc-linux-gnu/4.4.0-alpha20081010/cc1plus -fpreprocessed /home/prak/.ccache/enum_class.tmp.sandra.23558.ii -quiet -dumpbase enum_class.tmp.sandra.23558.ii -mtune=generic -march=i686 -auxbase-strip /home/prak/.ccache/tmp.hash.sandra.23558.o -std=c++0x -version -o /tmp/ccpib1aZ.s
GNU C++ (Gentoo 4.4.0_alpha20081010) version 4.4.0-alpha20081010  (experimental) (i686-pc-linux-gnu)
	compiled by GNU C version 4.4.0-alpha20081010  (experimental), GMP version 4.2.4, MPFR version 2.3.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 3bd1a7449bb261a218b8d8c78fb46226
enum_class_ice.cc: In function ‘E operator|(E, E)’:
enum_class_ice.cc:10: internal compiler error: in common_type, at cp/typeck.c:779
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.gentoo.org/> for instructions.
Comment 1 Piotr Rak 2008-10-28 23:35:04 UTC
Created attachment 16578 [details]
Test case
Comment 2 Volker Reichelt 2008-12-30 01:33:13 UTC
Confirmed.
Comment 3 Volker Reichelt 2009-06-06 20:11:59 UTC
This was fixed on the trunk and for GCC 4.4.1 by Jason's patch for PR38064.

Jason, would you mind adding this as another testcase to the testsuite so that we can close the bug?
Comment 4 Jason Merrill 2009-07-07 22:13:43 UTC
Done.