https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117004
Bug ID: 117004
Summary: Unexpected const variable type with decltype of
non-type template parameter of deduced type
Product: gcc
Version: 14.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
This is similar to #99631, but this example deals with scalars and still fails
on trunk. Attempted reduction:
#include <concepts>
template <int V> struct integral_constant {
static constexpr int value = V;
};
template <auto V>
using value_type = decltype(V);
void f() {
[]<class T>(T) {
// this fails on gcc (which thinks it's "const int")
// passes on clang
static_assert(std::same_as<value_type<T::value>, int>);
// .. but this DOES pass on gcc???
static_assert(__is_same(value_type<T::value>, int));
}(integral_constant<0>());
}
value_type<0> is int, but gcc sometimes thinks for more complicated spellings
of 0 that it is const int.