https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97200

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
clang rejects it as well as soon as you instantiate func1:

t3.ii:4:28: error: reference to local variable 'a' declared in enclosing
function 'func1<1>'
    int func1(void){return a;} 
                           ^
t3.ii:3:10: note: in instantiation of member function 'func1()::S::func1'
requested here
  struct S { 
         ^
t3.ii:8:14: note: in instantiation of function template specialization
'func1<1>' requested here
template int func1<1> ();
             ^
t3.ii:2:8: note: 'a' declared here
  int  a; 
       ^
1 error generated.


it looks like a correct error to me, not sure if the use of 'a' is dependent
and thus the error should be delayed to allow SFINAE (not sure if that exists
for function templates).

Reply via email to