https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94844
Bug ID: 94844
Summary: Simple nonsensical program accepted by g++ (rejected
by clang++)
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: robert at ocallahan dot org
Target Milestone: ---
Testcase:
#include <stdio.h>
template <typename T> void func(T s) {
if (s < 0) {
puts("WHAT");
}
}
typedef long unsigned Foo;
int main(void) {
func<long Foo>(-1);
}
g++ (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2):
compiles it and generates code that prints "WHAT".
clang version 9.0.1 (Fedora 9.0.1-2.fc31):
rejects it:
/home/roc/tmp/test.cc:9:13: error: type-id cannot have a name
func<long Foo>(-1);
^~~
clang++ looks right to me. It doesn't seem right to allow 'unsigned' to modify
'Foo' here. Doing that in a variable declaration is rejected.