From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6246 invoked by alias); 9 Apr 2007 06:34:40 -0000 Received: (qmail 6223 invoked by uid 48); 9 Apr 2007 06:34:30 -0000 Date: Mon, 09 Apr 2007 06:34:00 -0000 Subject: [Bug c++/31512] New: function template with member reference compile failure X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "gianni at mariani dot ws" 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: 2007-04/txt/msg00586.txt.bz2 The code below has 3 ways of declaring the template member function ObjInitSelDot(). One of them performs as desired, the other two do not. Comeau compiles all of them (albeit with a silly warning). As far as I can tell, all three should compile. template struct InitObject { private: struct xA {}; struct xB : xA {}; template struct Detect; struct NoMemb { char a[1]; }; struct Memb_MemberA { char a[2]; }; template inline static Memb_MemberA ObjInitSelDot( // 3 different signatures - one works 2 fail under gcc 4.1.1 // U & obj, xB * b, Detect< sizeof(U().MemberA) > * = 0 // ?? bug // U & obj, xB * b, Detect< sizeof(&U::MemberA) > * = 0 // Works // also ICE's on gcc 4.0.0 and earlier U & obj, xB * b, Detect< sizeof(((U*)0)->MemberA) > * = 0 // ?? bug ); template inline static NoMemb ObjInitSelDot( U & obj, xA * b ); public: inline int ObjTest() { typedef xB * bp; T obj = T(); return sizeof( ObjInitSelDot( obj, bp() ) ); } }; /////////// test code struct A { int a; char x[10]; }; struct B { int MemberA; char x[15]; }; int main() { InitObject().ObjTest(); InitObject().ObjTest(); } -- Summary: function template with member reference compile failure Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gianni at mariani dot ws GCC build triplet: i386-redhat-linux GCC host triplet: i386-redhat-linux GCC target triplet: i386-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31512