https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84045
Bug ID: 84045
Summary: ICE when is_nothrow_default_constructible is used
before #include<set>
Product: gcc
Version: 7.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: schlaffi at users dot sourceforge.net
Target Milestone: ---
The following valid code
#include <type_traits>
template <typename T, typename S>
struct dummy{
typedef std::is_nothrow_default_constructible<T> dc;
void fu()noexcept(dc::value){}
};
#include <set>
int main(){
std::set<int> bar;
return 0;
}
causes the ICE:
In file included from /usr/include/c++/7/set:60:0,
from ice.cc:9:
/usr/include/c++/7/bits/stl_tree.h: In instantiation of
‘std::_Rb_tree_key_compare<_Key_compare>::_Rb_tree_key_compare() [with
_Key_compare = std::less<int>]’:
ice.cc:12:16: required from here
/usr/include/c++/7/bits/stl_tree.h:146:7: internal compiler error: Segmentation
fault
_Rb_tree_key_compare()
The following changes make the code compile without error:
- include <set> before struct dummy
- force dc::value to be bool (e.g. not not dc::value or bool(dc::value))
- expand the typedef in dc::value
- have only one template parameter
But, it took me quite a while to find what line causes the error.
My gcc is
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin
--enable-initfini-array --with-isl --enable-libmpx
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC)