[Bug c++/87406] Implement -Wconstant-conversion and -Wbitfield-constant-conversion

2018-10-03 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87406

--- Comment #4 from Martin Liška  ---
(In reply to Eric Gallager from comment #3)
> Is clang's -Wbitfield-constant-conversion anything like the
> -Wbitfield-conversion flag requested in bug 39170?

It's similar, but if I see correctly the LLVM warning is only about constants:
https://godbolt.org/z/srLT8m

[Bug c++/87406] Implement -Wconstant-conversion and -Wbitfield-constant-conversion

2018-10-02 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87406

Eric Gallager  changed:

   What|Removed |Added

 CC||egallager at gcc dot gnu.org

--- Comment #3 from Eric Gallager  ---
Is clang's -Wbitfield-constant-conversion anything like the
-Wbitfield-conversion flag requested in bug 39170?

[Bug c++/87406] Implement -Wconstant-conversion and -Wbitfield-constant-conversion

2018-09-24 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87406

Manuel López-Ibáñez  changed:

   What|Removed |Added

 CC||manu at gcc dot gnu.org

--- Comment #2 from Manuel López-Ibáñez  ---
(In reply to Jonathan Wakely from comment #1)
> We do warn about this, but only with -Wconversion which is not in -Wall or
> -Wextra
> 
> c.cc:1:24: warning: conversion to ‘char’ from ‘int’ may alter its value
> [-Wconversion]
>  char f(int i) { return i; }


This is not the "constant" case. A testcase would be:

char foo(void) {
return 132;
} 

: In function 'char square()':
:3:12: warning: conversion from 'int' to 'char' changes value from
'132' to ''\3777604'' [-Wconversion]
 return 132;
^~~

I think the constant case should be safe for -Wall. It is a just a matter of
adding more specific flags.

[Bug c++/87406] Implement -Wconstant-conversion and -Wbitfield-constant-conversion

2018-09-24 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87406

--- Comment #1 from Jonathan Wakely  ---
We do warn about this, but only with -Wconversion which is not in -Wall or
-Wextra

c.cc:1:24: warning: conversion to ‘char’ from ‘int’ may alter its value
[-Wconversion]
 char f(int i) { return i; }
^

[Bug c++/87406] Implement -Wconstant-conversion and -Wbitfield-constant-conversion

2018-09-24 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87406

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-09-24
 Ever confirmed|0   |1
   Severity|normal  |enhancement