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

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

$
0
0

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)

 


Viewing all articles
Browse latest Browse all 1175

Trending Articles



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