>Submitter-Id: net >Originator: Franck Branjonneau >Organization: >Confidential: no >Synopsis: Bad instanciation path dependending of the template argument >Severity: serious >Priority: medium >Category: ice-on-legal-code rejects-legal >Class: >Release: 3.3.4 >Environment: System: Linux
host: i486-pc-linux-gnu build: i486-pc-linux-gnu target: i486-pc-linux-gnu >Description: Bad instanciation path dependending of the template argument. >How-To-Repeat: g++-3.4 compiles the following code: #include <iterator> #include <vector> template< unsigned _k > struct I {}; template< unsigned _k > struct C { typedef I< _k > I; struct S {}; }; template< unsigned _k > struct A; template< unsigned _k > struct S { typedef A< _k > A; typedef typename A::IS IS; template< int, unsigned _dummy= _k > struct Foo; template< typename _Iterator > inline _Iterator foo( _Iterator target) const; typename A::IS s1_; // # 1 typename C< _k >::S s2_; // # 2 }; template< unsigned _k > struct A { typedef C< _k > C; typedef typename C::S IS; }; template< unsigned _k > template< unsigned _dummy > struct S< _k >::Foo< 0, _dummy > { typedef S< _k > S; template< typename _Iterator > _Iterator operator()( _Iterator target) const; }; template< unsigned _k > template< unsigned _dummy > template< typename _Iterator > _Iterator S< _k >::Foo< 0, _dummy >::operator()( _Iterator target) const { return target; } template< unsigned _k > template< typename _Iterator > inline _Iterator S< _k >::foo( _Iterator target) const { return Foo< 0 >().template operator()(target); } int main( int argc, char * argv[]) { S< 0 > s; s.foo(0); std::vector< int > v; // s.foo(std::back_inserter(v)); // # 3 } But, if I uncomment #3, g++ gives `S<_k>::s1_' has incomplete type on #2 an seg fault on #3. >Fix: