https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91397
Bug ID: 91397 Summary: -Wstringop-overflow specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 Product: gcc Version: 9.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steinar+gcc at gunderson dot no Target Milestone: --- Hi, We saw this coming only with GCC 10 (probably different inlining decisions), but the reduced test case also triggers with 9, so I'm going to file it against 9.1.0. This test case is reduced from MySQL 8.0 (osfile0.cc): #include <string.h> #include <stdlib.h> char *allocate(unsigned long g) { if (g == 0) return (char *)malloc(0); for (;;) ; } char *i; char *j(long k) { char *l(allocate(k + 1)); memcpy(l, i, k); return l; } atum17:~> g++-9 -O2 -Wstringop-overflow -c os0file.cc os0file.cc: In function ‘char* j(long int)’: os0file.cc:12:9: warning: ‘void* memcpy(void*, const void*, size_t)’ specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=] 12 | memcpy(l, i, k); | ~~~~~~^~~~~~~~~ I don't even understand what the warning means (“specified bound” of what?), but it looks spurious to me. Perhaps some signed/unsigned confusion? Since the reduction is somewhat nonsensical with the empty infinite loop in there, I'm also including an unreduced test case. With GCC 9.1.0 and -O2, it gives the same warning.