[Bug c++/54763] New: Crash with enable_if (instead of recursive template errors)
pkeir at outlook dot com
gcc-bugzilla@gcc.gnu.org
Sun Sep 30 21:59:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54763
Bug #: 54763
Summary: Crash with enable_if (instead of recursive template
errors)
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: pkeir@outlook.com
Created attachment 28308
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28308
C++11 code which causes an internal compiler error
The attached minimised C++11 test case causes an internal compiler error. Clang
instead gives an endless list of errors such as:
fatal error: recursive template instantiation
exceeded maximum depth of 512
The code, which is also shown below, will run correctly if the enable_if is
instead set to: std::enable_if<(I>0)>::type.
#include <type_traits>
template <unsigned>
struct tint {};
double zod(tint<0>) { return 3.142; }
template <
unsigned I,
typename = typename std::enable_if<(I>0),decltype(zod(tint<I-1>()))>::type
>
decltype(zod(tint<I-1>()))
zod(tint<I>) {
return zod(tint<I-1>());
}
int main(int argc, char *argv[])
{
zod(tint<0>());
return 0;
}
More information about the Gcc-bugs
mailing list