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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-05-02
                 CC|                            |marxin at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, any of releases I have (4.5.0+) can't catch that.

Just a nit: -Wstrict-overflow needs -fstrict-overflow and the warning has
various levels. Anyhow -Wstrict-overflow=5 and -fstrict-overflow does not work.

Btw. -fsanitize=undefined can catch that easily:

$ cat pr80592.c
#define TU_SIZE_RECOMMENDED     (0x3f << 16) 

void g( int a)
{
  __builtin_printf ("value: %d\n", a);
}

int main()
{
    int max_tu_symbol = TU_SIZE_RECOMMENDED - 1;

    g(max_tu_symbol << 23);

    return 0;
}

g++ -O2 -fsanitize=undefined pr80592.c && ./a.out 
pr80592.c:12:21: runtime error: left shift of 4128767 by 23 places cannot be
represented in type 'int'
value: -8388608

Reply via email to