https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125406
Bug ID: 125406
Summary: No warning for using a [[deprecated]] enum in a
variable template
Product: gcc
Version: 16.1.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
template<typename T>
struct limits
{
[[deprecated]] static constexpr int value = 1;
};
#ifdef WARNS
static_assert( limits<int>::value == 1 );
#else
template<typename T> constexpr bool var = limits<T>::value == 1;
static_assert( var<int> );
#endif
With -DWARNS defined we get a warning as expected:
e.cc:8:29: warning: ‘limits<int>::value’ is deprecated
[-Wdeprecated-declarations]
8 | static_assert( limits<int>::value == 1 );
| ^~~~~
e.cc:4:39: note: declared here
4 | [[deprecated]] static constexpr int value = 1;
| ^~~~~
But without -DWARNS (when the deprecated member is used in the variable
template's initializer) there is no warning.