[Bug c++/53498] Compiler crashes during C++11 template magic compilation
daniel.kruegler at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Sun May 27 15:33:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53498
Daniel Krügler <daniel.kruegler at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler at
| |googlemail dot com
--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-05-27 14:32:40 UTC ---
While the test code is somewhat broken, I found some suspicious compiler
behaviour when rewriting this into the following form, compiled with
-std=c++11 -Wall using gcc 4.8.0 20120520 (experimental):
//------------
template<typename... Args>
struct A
{
template<typename U>
static
auto a(const U& u, const Args&... args, int) -> decltype(u.print(args...))
{
return u.print(args...);
}
template<typename U>
static
int a(const U& u, const Args&... args, ...)
{
return 0;
}
};
template<typename... Args>
struct B
{
template<typename U>
static
void b(const U& u, const Args&... args, decltype(A<Args...>::a(u, args...,
0)) dummy)
{
}
};
int main() {
A<int>::a(0, 0, 0); // OK
B<int>::b(0, 0, 0); // ?
}
//------------
On my mingw build there is no diagnostics and no binary output produced except
that the compiler does not return successfully due to the last line
instantiating B<int>. In my experience that gives a seg fault on other systems,
so I recommend to run it through another system.
More information about the Gcc-bugs
mailing list