https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85651
Bug ID: 85651 Summary: Invalid -Warray-bounds warning with -O3 Product: gcc Version: 8.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gburca-gnu at ebixio dot com Target Milestone: --- Created attachment 44069 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44069&action=edit Code demonstrating issue https://godbolt.org/g/LmJDVa When compiled with g++ 8.1.0 and "-c -std=gnu++17 -Wall -Werror -O3" the attached code (alternatively, see link above) issues the following array-bounds warning. Furthermore, the warning can not be ignored with diagnostic pragmas. cc1plus: error: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ offset [-9223372036854775799, -9223372036854775801] is out of the bounds [0, 128] of object ‘logBuilder’ with type ‘LogBuilder’ [-Werror=array-bounds] Ways to make the warning go away include: - Compiling with -O2 - Changing the "ptr_" type to size_t No warning is issued when compiled with 7.3.