Created attachment 28122 [details] The preprocessed dump from the error. The following code fails with a segmentation fault: #include <memory> template<typename T> using CallbackPtr = const std::shared_ptr<const T>; template<typename C, typename T> using CallbackFunPtr = void (C::*)(CallbackPtr<T>); int main () { return 0; } [matt test] g++ --std=c++11 -Wall -Wextra -Werror -pedantic -pedantic-errors main.cpp main.cpp:7:49: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://bugzilla.redhat.com/bugzilla> for instructions. Preprocessed source stored into /tmp/ccuw4zjD.out file, please attach this to your bugreport. However changing CallbackFunPtr to: template<typename C, typename T> using CallbackFunPtr = void (C::*)(const std::shared_ptr<const T>); It's OK. [matt test] uname -r 3.5.2-3.fc17.x86_64 [matt test] gcc --version gcc (GCC) 4.7.0 20120507 (Red Hat 4.7.0-5) Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This is still an error on 4.7.2. It is the const before the std::shared_ptr<const T> that is the problem: template<typename T> #if (__GNUC__ <= 4) && (__GNUC_MINOR__ <= 7) && (__GNUC_PATCHLEVEL__ <= 2) using CallbackPtr = std::shared_ptr<const T>; #else // This causes a segmentation fault on G++ 4.7.2 // Bug Report: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54466 using CallbackPtr = const std::shared_ptr<const T>; #endif
confirmed
A shorter self contained testcase, not involving the whole std::shared_ptr, would certainly help. Dodji, are there any chances you can look into this issue? The alias decls seem determinant.
template<typename T> struct X { }; template<typename T> using Y = const X<T>; template<typename T> using Z = Y<T>;
Excellent.
The second alias doesn't even have to be a template to show the problem: template<typename T> struct X { }; template<typename T> using Y = const X<T>; using Z = Y<int>;
Sorry about the bloated bug report - that was how I came across it. In the future I'll submit smaller test cases. Thanks for looking into this.
"paolo.carlini at oracle dot com" <gcc-bugzilla@gcc.gnu.org> a écrit: > Dodji, are there any chances you can look into this > issue? The alias decls seem determinant. Sure. Sorry for the delay, I was buried into something else. I am looking into this now.
A candidate patch has been sent to http://gcc.gnu.org/ml/gcc-patches/2012-10/msg02472.html.
Author: dodji Date: Tue Nov 13 16:07:39 2012 New Revision: 193479 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193479 Log: PR c++/54466 - ICE with alias template which type-id is const qualified Consider this short example: template<typename T> struct X { }; template<typename T> using Y = const X<T>; using Z = Y<int>; G++ crashes in lookup_class_template_1 while trying to build the alias template instantiation Y<int>. I think this is indirectly due to the fact that that lookup_class_template_1 can now yield a const qualified type like 'const X<T>'. As a consequence, the code in lookup_template_class_1 that was trying to access the TYPE_STUB_DECL field of the result of lookup_template_class_1 should now be adjusted to access the TYPE_STUB_DECL of the main variant of the resulting type instead (and that is TYPE_MAIN_DECL); because qualified types (constructed with build_qualified_type) have their TYPE_STUB_DECL set to NULL. Fixed thus and tested on x86_64-unknown-linux-gnu against trunk. gcc/cp PR c++/54466 * pt.c (lookup_template_class_1): TYPE_STUB_DECL should be accessed on the main variant of the type. gcc/testsuite/ * g++.dg/cpp0x/alias-decl-26.C: New test file. In the example of this patch, g++ crashes when trying to build the alias template Y<int Added: trunk/gcc/testsuite/g++.dg/cpp0x/alias-decl-26.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog
Fixed in trunk (4.8).
@Dodji, thanks for fixing this :) What release will this be in? 4.8.1?
4.8.0
"mattyclarkson at gmail dot com" <gcc-bugzilla@gcc.gnu.org> a écrit: > @Dodji, thanks for fixing this :) You are welcome. Sorry for the delay. > What release will this be in? 4.8.1? As Jon said, 4.8.0. Cheers.
*** Bug 53026 has been marked as a duplicate of this bug. ***
*** Bug 57152 has been marked as a duplicate of this bug. ***