Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
The Intel sign-in experience is changing in February to support enhanced security controls. If you sign in, click here for more information.

Template code compilation issue #2

de666
Beginner
159 Views
this code does not compile with icc11 however is valid c++
it compiles with msvc versions 7, 7.1 & 8

[cpp]#include    
  
template struct s;   
template<> struct s {};   
template<> struct s : public s   
{};   
  
struct Int : public s {};   
  
template   
void foo(const s&)   
{ std::cout << "in foo(const s<" << typeid(type).name() << ">&)n"; }   
  
int main()   
{   
  Int i;   
  foo(i);  //here an error appears   
  return 0;   
}[/cpp]

previous discussion: http://software.intel.com/en-us/forums/showthread.php?t=70491
0 Kudos
2 Replies
Judith_W_Intel
Employee
159 Views
Quoting - de666
this code does not compile with icc11 however is valid c++
it compiles with msvc versions 7, 7.1 & 8

[cpp]#include    
  
template struct s;   
template<> struct s {};   
template<> struct s : public s   
{};   
  
struct Int : public s {};   
  
template   
void foo(const s&)   
{ std::cout << "in foo(const s<" << typeid(type).name() << ">&)n"; }   
  
int main()   
{   
  Int i;   
  foo(i);  //here an error appears   
  return 0;   
}[/cpp]

previous discussion: http://software.intel.com/en-us/forums/showthread.php?t=70491

this is the same issue as in the previous discussion (link above)
de666
Beginner
159 Views
ok
let's continue in the old thread
you may want to delete this one
Reply