This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/57170] Diagnostic for a negative case when switching over unsigned comes from -Wsign-conversion instead of -Wpedantic or -Wnarrowing
- From: "egallager at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 24 Aug 2017 01:41:35 +0000
- Subject: [Bug c++/57170] Diagnostic for a negative case when switching over unsigned comes from -Wsign-conversion instead of -Wpedantic or -Wnarrowing
- Auto-submitted: auto-generated
- References: <bug-57170-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57170
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
Status|RESOLVED |NEW
Last reconfirmed| |2017-08-24
Resolution|INVALID |---
Summary|No diagnostic for a |Diagnostic for a negative
|negative case when |case when switching over
|switching over unsigned |unsigned comes from
| |-Wsign-conversion instead
| |of -Wpedantic or
| |-Wnarrowing
Ever confirmed|0 |1
--- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to TC from comment #2)
> As comment #0 alluded to - perhaps a bit opaquely - this code is ill-formed
> in C++11 and later. [stmt.switch] requires the case expression to be "a
> converted constant expression ([expr.const]) of the promoted type of the
> switch condition", and a narrowing conversion cannot be used in a converted
> constant expression. The standard requires a diagnostic, which GCC fails to
> provide even with -pedantic.
>
> (Meanwhile, using unsigned char or unsigned short there is actually
> well-formed if they get promoted to int as they usually do.)
>
> So, unless you are saying that GCC's full conformance mode requires
> -Wsign-conversion, I don't see how this bug is invalid.
OK, reopening and retitling to make it clearer.