From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9251 invoked by alias); 28 Aug 2009 05:13:15 -0000 Received: (qmail 9221 invoked by uid 48); 28 Aug 2009 05:13:00 -0000 Date: Fri, 28 Aug 2009 05:13:00 -0000 Message-ID: <20090828051300.9220.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/37920] ICE (segv) with typename typeof in local struct In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "mbarrien at cs dot stanford dot edu" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-08/txt/msg02215.txt.bz2 ------- Comment #5 from mbarrien at cs dot stanford dot edu 2009-08-28 05:12 ------- I just ran into this bug too. Before I found this bug report, I did some more investigation to characterize the bug a little more. I am including my version of the reduced test case, with more commentary inline. -- // Cause: Use of __typeof__ on a templated type (dependent upon template arguments of outer function/class) as the type of an argument for any function in a locally defined class crashes g++. Since this successfully typechecks, I suspect that during symbol lookup in some IR generating phase, for arguments to a function of a local class, if a __typeof__ is involved, g++ does not properly lookup symbols in the outer function/class symbol table. template struct VertexData; template void init() { // Making non-templated function eliminates ICE. (Also ICEs for non-templated member function in a templated class.) VertexData* v0; // Making this non-template eliminates ICE. Changing LM to int eliminates ICE. typedef __typeof__(v0) v0_type_; // Using VertexData instead of __typeof__(v0) eliminates ICE. Using __decltype(v0) still causes ICE in GCC 4.3.4, but eliminates ICE in GCC 4.4 struct MeshConditionalInit { // Removing body of struct eliminates ICE. MeshConditionalInit(v0_type_& v0) { } // Removing argument eliminates ICE. Using v0_type_ only in body and not as argument eliminates ICE. }; // ICE still occurs when used as function argument instead of constructor argument. MeshConditionalInit bar138(v0); } int main(int argn, char ** argv) { init(); } -- ICE occurs with no special compile flags in the following standard distribution packages of GCC: 4.1.3, 4.2.4, and 4.3.3 on Ubuntu 9.04 4.0.1 and 4.2.1 on Mac OS X 10.5 (the versions with XCode) 4.4.0 on Mac OS X 10.5 (MacPorts build) And because I got bored, here's a 140-character twitterable version of an even smaller test case (inlines the typeof into the constructor's argument, removing the typedef, which may not be legal, but definitely still causes an ICE in GCC): -- /*GCC Instacrash*/ template class C;template void f() {C* i;struct S{S(__typeof__(i)& i){}}s(i);}int main(){f();} -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37920