Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

icc 17.0.0 accepts illegal C++ code with shadowed template parameters

$
0
0

Compiler version and platform: 

Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.0.098 Build 20160721

According to the C++ standard, it is illegal to have a declaration that shadows a template parameter. 

$ icc -c small.cpp
$
$ g++-6.2 -c small.cpp
small.cpp:3:7: error: declaration of ‘int A<T>::T’ shadows template parameter
   int T;
       ^
small.cpp:1:12: note: template parameter ‘T’ declared here
 template < int T > struct A
            ^~~
$ clang++-3.8 -c small.cpp
small.cpp:3:7: error: declaration of 'T' shadows template parameter
  int T;
      ^
small.cpp:1:16: note: template parameter is declared here
template < int T > struct A
               ^
1 error generated.
$
$ cat small.cpp
template < int T > struct A
{
  int T;
};
$ 

 


Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>