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

            Bug ID: 100442
           Summary: Spurious -Wstringop-overread error with odd boundaries
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andres at anarazel dot de
  Target Milestone: ---

Hi,

When compiling one of postgres' source files with -O3 I see the following:

gcc-11 -O3 -Wall -o /dev/null -c tsvector_op.i

In function 'tsCompareString',
    inlined from 'tsCompareString' at
/home/andres/src/postgresql/src/backend/utils/adt/tsvector_op.c:1147:1,
    inlined from 'tsvector_bsearch' at
/home/andres/src/postgresql/src/backend/utils/adt/tsvector_op.c:410:9:
/home/andres/src/postgresql/src/backend/utils/adt/tsvector_op.c:1164:23:
warning: 'memcmp' specified bound [18446744073709551612, 18446744073709551615]
exceeds maximum object size 9223372036854775807 [-Wstringop-overread]
 1164 |                 cmp = memcmp(a, b, Min(lena, lenb));
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                   

which does not seem plausible ;). As far as I can tell the values actually
passed to memcmp are reasonable.

I've attached both the preprocessed source file. I tried to reduce it using
creduce - but it hung and reported a bug (which I did, an hour ago).

andres@awork3:~/src/postgresql$ gcc-11 --version
gcc-11 (Debian 11.1.0-1) 11.1.0

This also happens with gcc-10 (except reported as -Wstringop-overflow=), but
not 9.


Regards,

Andres

Reply via email to