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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(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;
} 

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

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

Reply via email to