[cfe-dev] ADL causing implicit template class instantiation failure

Marco marco.diiga at gmail.com
Tue Sep 23 08:57:27 PDT 2014


I'm taking a look at a possible clang issue with the following code:
___________________________
struct incomplete; 

template<class T> 
struct A { T d; }; 

template <class T> 
struct B { }; 

template<typename T> void func(T &t); 

int main() { 
    B<A<incomplete>> a, b; 
    a = b; 
} 
___________________________


this code causes clang to emit an error "incomplete type T d;". I searched
in the cpp standard and found nothing related to ADL causing an implicit
instantiation in this case. So I started researching clang's source and I
believe this is what is happening:

- ADL process starts
- A<incomplete> is tried to be instantiated to have a better ADL set (and
also for other reasons as explained here:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140310/101487.html
) with a "complain = false" flag (so it won't complain if the template can't
be instantiated)
- The flag is lost during instantiation of the template members, I'm posting
the entire MSVC stack trace here: http://nopaste.info/829f7404e6.html

I spoke with David Blaikie about this issue and told me to give it a wider
audience here.

What is strange to me is that also gcc behaves in the same way as clang, so
it might as well mean that I'm getting something wrong and clang/gcc are
both correct in this.



--
View this message in context: http://clang-developers.42468.n3.nabble.com/ADL-causing-implicit-template-class-instantiation-failure-tp4041705.html
Sent from the Clang Developers mailing list archive at Nabble.com.



More information about the cfe-dev mailing list