public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94844] New: Simple nonsensical program accepted by g++ (rejected by clang++)
@ 2020-04-29 9:07 robert at ocallahan dot org
2020-04-29 9:18 ` [Bug c++/94844] " redi at gcc dot gnu.org
2020-04-30 7:06 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: robert at ocallahan dot org @ 2020-04-29 9:07 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/94844] Simple nonsensical program accepted by g++ (rejected by clang++)
2020-04-29 9:07 [Bug c++/94844] New: Simple nonsensical program accepted by g++ (rejected by clang++) robert at ocallahan dot org
@ 2020-04-29 9:18 ` redi at gcc dot gnu.org
2020-04-30 7:06 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-29 9:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94844
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is intentional. You get a diagnostic with -pedantic or -pedantic-errors
94844.cc: In function ‘int main()’:
94844.cc:9:8: warning: ‘long’ specified with ‘Foo’ {aka ‘long unsigned int’}
[-Wpedantic]
9 | func<long Foo>(-1);
| ^~~~
*** This bug has been marked as a duplicate of bug 80516 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/94844] Simple nonsensical program accepted by g++ (rejected by clang++)
2020-04-29 9:07 [Bug c++/94844] New: Simple nonsensical program accepted by g++ (rejected by clang++) robert at ocallahan dot org
2020-04-29 9:18 ` [Bug c++/94844] " redi at gcc dot gnu.org
@ 2020-04-30 7:06 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-04-30 7:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94844
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> This is intentional. You get a diagnostic with -pedantic or -pedantic-errors
>
> 94844.cc: In function ‘int main()’:
> 94844.cc:9:8: warning: ‘long’ specified with ‘Foo’ {aka ‘long unsigned int’}
> [-Wpedantic]
> 9 | func<long Foo>(-1);
> | ^~~~
>
One which is even better than clang produces even.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-30 7:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 9:07 [Bug c++/94844] New: Simple nonsensical program accepted by g++ (rejected by clang++) robert at ocallahan dot org
2020-04-29 9:18 ` [Bug c++/94844] " redi at gcc dot gnu.org
2020-04-30 7:06 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).