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

            Bug ID: 80592
           Summary: gcc fails to detect overflow in shift statement
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

For this C/C++ source code, derived from the linux kernel:

#define TU_SIZE_RECOMMENDED     (0x3f << 16) 

extern void g( int);

void f()
{
    int max_tu_symbol = TU_SIZE_RECOMMENDED - 1;

    g(max_tu_symbol << 23);
}

gcc doesn't seem able to detect the overflow into 44 bits.

$ ~/gcc/results/bin/gcc -c -O2 -Wall -Wextra -Wstrict-overflow -Wconversion
may2b.cc
$

Reply via email to