This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53498] Compiler crashes during C++11 template magic compilation
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 27 May 2012 14:32:40 +0000
- Subject: [Bug c++/53498] Compiler crashes during C++11 template magic compilation
- Auto-submitted: auto-generated
- References: <bug-53498-4@http.gcc.gnu.org/bugzilla/>
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.