llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Should clang warn about partial specialization after instantiation?

Open llvmbot opened this issue 11 years ago • 2 comments

Bugzilla Link 25367
Version unspecified
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @zygoloid

Extended Description

In the code below, T2<int,int> will not have mytype member, as T2<int,int> is first instantiated in line 2 and then T2<T,int> specialized in line 3.

1 template <typename T, typename> struct T2 {}; 2 template struct T2<int, int>; 3 template struct T2<T, int> { typedef int mytype; }; 4 void foo() { T2<int,int>::mytype i; }

If we swap lines 2 and 3, T2<int,int> will have mytype as T2<int,int> will find and use the specialization T2<T,int>.

Similar to error: explicit specialization after instantiation, should we error or warn about this, a specialization that would have changed existing instantiation if it would have come before it?

llvmbot avatar Nov 01 '15 00:11 llvmbot

@llvm/issue-subscribers-c-1

llvmbot avatar Jan 17 '22 18:01 llvmbot

Related: #21530

MitalAshok avatar Jul 31 '24 10:07 MitalAshok