https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83777

--- Comment #2 from Zahira Ammarguellat <Zahira.Ammarguellat at intel dot com> 
---
>From my understanding, the test case is trying to instantiate "C" with "void *"
type, which doesn't have a member called "M". 
I think this should generate an error?

Clang and MSVC both give an error compiling this test case.

bash-4.2$ cat 8528.cpp
template <class T> class C
{
  static const int BlockSize = T::M;
public:
  static const int type = 1;
};

int foo() { return C<void*>::type == 1; }
bash-4.2$

bash-4.2$ clang -v
clang version 6.0.0
bash-4.2$ clang -c 8528.cpp
8528.cpp:3:32: error: type 'void *' cannot be used prior to '::' because it has
      no members
  static const int BlockSize = T::M;
                               ^
8528.cpp:8:20: note: in instantiation of template class 'C<void *>' requested
      here
int foo() { return C<void*>::type == 1; }
                   ^
1 error generated.
bash-4.2$
ksh-3.2$ cl -c 8528.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

8528.cpp
8528.cpp(3): error C2825: 'T': must be a class or namespace when followed by
'::'
8528.cpp(8): note: see reference to class template instantiation 'C<void *>'
being compiled
8528.cpp(3): error C2510: 'T': left of '::' must be a class/struct/union
8528.cpp(3): error C2065: 'M': undeclared identifier
8528.cpp(3): error C2131: expression did not evaluate to a constant
8528.cpp(3): note: failure was caused by non-constant arguments or reference to
a non-constant symbol
8528.cpp(3): note: see usage of 'M'
ksh-3.2$

Reply via email to