https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86608
Bug ID: 86608
Summary: volatile variable is taken as a constexpr
Product: gcc
Version: 8.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tadeus.prastowo at unitn dot it
Target Milestone: ---
The following program is ill-formed based on
http://eel.is/c++draft/temp.arg.nontype (#1 and #2) and
http://eel.is/c++draft/expr.const#2.7. However,
GCC 8.1 compiles fine (https://godbolt.org/g/o8UPiJ)
as well as any GCC >= 6.1 available in godbolt, but
clang-6.0 (https://godbolt.org/g/HUQXUM) and
GCC 5.5 (https://godbolt.org/g/MQRCdE) as well as
any GCC older than 5.5 but >= 4.9.0 correctly reject
the program.
template<typename T, T v> struct X {};
int main() {
static constexpr volatile int a = 3;
constexpr volatile int b = 2;
return (sizeof(X<decltype(a), a>) + sizeof(X<decltype(b), b>));
}
So, GCC >= 6.1 should be fixed to reject the program.