[Bug c++/83777] Invalid dependent initialization of a static data member.

2024-03-14 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83777

Andrew Pinski  changed:

   What|Removed |Added

   Last reconfirmed|2018-01-11 00:00:00 |2024-3-14
 Status|WAITING |NEW
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=86565

--- Comment #3 from Andrew Pinski  ---
I am not 100% sure if rejecting this is required if C:BlockSize is not
used.

[Bug c++/83777] Invalid dependent initialization of a static data member.

2018-01-11 Thread Zahira.Ammarguellat at intel dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83777

--- Comment #2 from Zahira Ammarguellat  
---
>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 C
{
  static const int BlockSize = T::M;
public:
  static const int type = 1;
};

int foo() { return C::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' requested
  here
int foo() { return C::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'
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$

[Bug c++/83777] Invalid dependent initialization of a static data member.

2018-01-11 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83777

Richard Biener  changed:

   What|Removed |Added

   Keywords||accepts-invalid
 Status|UNCONFIRMED |WAITING
   Last reconfirmed||2018-01-11
Version|unknown |7.2.1
 Ever confirmed|0   |1

--- Comment #1 from Richard Biener  ---
Are you sure?  It looks like C::type doesn't instantiate C
because it isn't dependent?

clang accepts the testcase without error as well.