[Bug c++/60999] New: [4.9 Regression] ICE when static_cast from constexpr in specialization of template-class

D.Bahadir at GMX dot de gcc-bugzilla@gcc.gnu.org
Tue Apr 29 12:32:00 GMT 2014


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

            Bug ID: 60999
           Summary: [4.9 Regression] ICE when static_cast from constexpr
                    in specialization of template-class
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: D.Bahadir at GMX dot de

Created attachment 32705
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32705&action=edit
source which can reproduce the ICE

The following code produces an internal compiler error (ICE) in GCC 4.9, but
did compile fine in GCC 4.8:

<code>

  // general template
  template <typename A>
  struct foo
  {
  };

  // template specialization
  template<>
  struct foo<int>
  {
      static constexpr int code = 42;
      unsigned int bar = static_cast<unsigned int>(code);
      // ICE at static_cast during instantiation. --^
  };

  // instantiation
  foo<int> a;

</code>

Compiling with the following line (using GCC 4.9) reproduced the ICE:
  g++ -Wall -Wextra -std=c++11 -c ICE.cpp


The output of 'g++ -v -save-temps -Wall -Wextra -std=c++11 -c ICE.cpp' yields
the following information:


Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.9-20140406-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap
--enable-plugin --with-system-zlib --disable-browser-plugin
--enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.0 20140405 (experimental) [trunk revision 209157] (Ubuntu
4.9-20140406-1ubuntu1) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-std=c++11' '-c'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.9/cc1plus -E -quiet -v -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE ICE.cpp -mtune=generic -march=x86-64 -std=c++11
-Wall -Wextra -fpch-preprocess -fstack-protector -Wformat -Wformat-security -o
ICE.ii
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/4.9"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.9
 /usr/include/x86_64-linux-gnu/c++/4.9
 /usr/include/c++/4.9/backward
 /usr/lib/gcc/x86_64-linux-gnu/4.9/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-std=c++11' '-c'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.9/cc1plus -fpreprocessed ICE.ii -quiet
-dumpbase ICE.cpp -mtune=generic -march=x86-64 -auxbase ICE -Wall -Wextra
-std=c++11 -version -fstack-protector -Wformat -Wformat-security -o ICE.s
GNU C++ (Ubuntu 4.9-20140406-1ubuntu1) version 4.9.0 20140405 (experimental)
[trunk revision 209157] (x86_64-linux-gnu)
    compiled by GNU C version 4.9.0 20140405 (experimental) [trunk revision
209157], GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (Ubuntu 4.9-20140406-1ubuntu1) version 4.9.0 20140405 (experimental)
[trunk revision 209157] (x86_64-linux-gnu)
    compiled by GNU C version 4.9.0 20140405 (experimental) [trunk revision
209157], GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 6752b609dd6385b31002233d89fe2356
ICE.cpp:17:10:   in constexpr expansion of ‘a.foo<int>::foo()’
ICE.cpp:17:10: internal compiler error: unexpected expression
‘static_cast<unsigned int>(foo<int>::code)’ of kind static_cast_expr
 foo<int> a;
          ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.9/README.Bugs> for instructions.
Preprocessed source stored into /tmp/cc5DJH1d.out file, please attach this to
your bugreport.


More information about the Gcc-bugs mailing list