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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Hello.

Thanks for the report, it's actually very similar to PR83266.
Here:

> $ cat small.c
> int func(unsigned short p1, unsigned int p2)
> {
>     int i = 0;
>     if (~p1) 

This expression is always true, because due to integral promotion:
https://stackoverflow.com/a/30474166

The expression has return type 'int' and thus it's impossible to get false
here.

>         i = i + 1;
> 
>     if ((unsigned int)(~p1)) 

On the other hand, here you need to make the test.

>         i = i + 2;
> 
>     if (~p2) 

Likewise here.

Reply via email to