Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
18 Views

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

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
Highlighted
Moderator
18 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