This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/80793] three signed conversion warnings for the same expression
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 21 Feb 2018 21:42:55 +0000
- Subject: [Bug c/80793] three signed conversion warnings for the same expression
- Auto-submitted: auto-generated
- References: <bug-80793-4@http.gcc.gnu.org/bugzilla/>
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.