This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/57170] No diagnostic for a negative case when switching over unsigned


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57170

TC <rs2740 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rs2740 at gmail dot com

--- Comment #2 from TC <rs2740 at gmail dot com> ---
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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]