Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Compilation error when compiling simple (valid) C++ code

Poletti__Marco
Beginner
428 Views

Compiling the following code:

template <typename T>
struct Outer {
  struct Inner {
    template <typename U>
    Outer<U> foo();
  };
};
template <typename T>
template <typename U>
Outer<U> Outer<T>::Inner::foo() {
  return {};
}

Fails to compile with ICC 19.0.0.117, while it should be correct.
GCC and Clang can compile this without issues.

ICC emits the following compilation errors:

main.cpp(10): warning #2357: "Outer<U>" cannot be specified in a template member definition -- "Outer<T>" assumed instead
  Outer<U> Outer<T>::Inner::foo() {
  ^

main.cpp(10): error: declaration is incompatible with function template "Outer<U> Outer<T>::Inner::foo<U>()" (declared at line 5)
  Outer<U> Outer<T>::Inner::foo() {
                            ^

compilation aborted for main.cpp (code 2)

 

0 Kudos
1 Reply
Viet_H_Intel
Moderator
428 Views

 

Thanks for report this issue. I've filed a bug with the Developer. The internal case number is CMPLRS-52589.

Regards,

Viet

0 Kudos
Reply