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

            Bug ID: 125656
           Summary: "warning: left shift count >= width of type
                    [-Wshift-count-overflow]" inaccurate
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mattreecebentley at gmail dot com
  Target Milestone: ---

GCC reports warning for following code:
buffer[PLF_ARRAY_CAPACITY - 1] |= std::numeric_limits<storage_type>::max() <<
(PLF_TYPE_BITWIDTH - (PLF_ARRAY_CAPACITY_BITS - total_size));

where PLF_TYPE_BITWIDTH == 64 (or any other size)
and:
#define PLF_ARRAY_CAPACITY ((total_size + PLF_TYPE_BITWIDTH - 1) /
PLF_TYPE_BITWIDTH) // ie. round up to nearest unit of storage
#define PLF_ARRAY_CAPACITY_BITS (PLF_ARRAY_CAPACITY * PLF_TYPE_BITWIDTH)

As you can see, PLF_ARRAY_CAPACITY_BITS will always be >= total_size, since
PLF_ARRAY_CAPACITY rounds up to the nearest unit of storage.

Therefore the warning is incorrect.
This warning did not appear in 13.2

Reply via email to