c++ - Template constructor fails in MSVC due to name collision of member function with argument type -


the following code snippit fails compile in msvc 18.00.31101 error below succeeds in gcc 4.9.2 , clang 3.6.0. scoping argument type or including struct keyword in declaration resolves error. compiler bug or undefined behavior?

#include <cstdlib>  struct {     int b; };  struct snap {     template<size_t tsize>     snap(const (&)[tsize]) {         // tsize     }      void a() {} };  int main() {     pop[] = { {1}, {2}, {3} };      snap crackle(pop);      return 0; } 

.

1> <...>: error c2664: 'snap::snap(const snap &)' : cannot convert argument 1 'a [3]' 'const snap &' 1>          reason: cannot convert 'a [3]' 'const snap' 1>          no constructor take source type, or constructor overload resolution ambiguous 

this ill-formed no diagnostic required. [basic.scope.class]/p1:

2) name n used in class s shall refer same declaration in context , when re-evaluated in completed scope of s. no diagnostic required violation of rule.

the name a evaluated in context refers ::a, refers snap::a when re-evaluated in completed scope of snap.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -