https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96478
Bug ID: 96478
Summary: GCC accepts enum definition in alignas()
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: accepts-invalid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: haoxintu at gmail dot com
Target Milestone: ---
Hi, all.
This code might be a invalid code, but GCC accepts it well. Other mainstream
compilers reject this code.
Code:
namespace {
template <class> int foo(){return 0;}
template <>
alignas (enum e{}) int foo<int>();
}
Output in Clang:
error: '(anonymous namespace)::e' cannot be defined in a type specifier
Output in ICC:
error: type definition is not allowed
Every version from GCC-6.1 onwards behaves the same.
Thanks,
Haoxin