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/80793] three signed conversion warnings for the same expression


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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-02-21
                 CC|                            |manu at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #0)

There are several issues conflated here.

> t.c: In function ‘f’:
> t.c:3:46: warning: signed and unsigned type in conditional expression
> [-Wsign-compare]
>    unsigned char c = i ? (-__SCHAR_MAX__ - 1) : 1U;

This warning should be moved to where -Wsign-conversion is handled to avoid
emitting both.

The reason we cannot simply remove -Wsign-compare is because -Wsign-conversion
is not enabled by neither -Wall nor -Wextra, while -Wsign-compare is.

The reason -Wsign-conversion is not enabled by neither -Wall nor -Wextra is
because it has annoying false positives like PR40752. Clang doesn't have those.

> t.c:3:46: warning: negative integer implicitly converted to unsigned type
> [-Wsign-conversion]

This is same warning as Clang gives, just less informative than Clang's.
Printing the types should be easy.

> t.c:3:21: warning: conversion to ‘unsigned char’ alters ‘unsigned int’
> constant value [-Wconversion]
>    unsigned char c = i ? (-__SCHAR_MAX__ - 1) : 1U;

This warning is a bug in my opinion. Probably the patch in PR40752 silences it.

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