https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98465
--- Comment #26 from Martin Sebor <msebor at gcc dot gnu.org> --- I tried the __builtin_object_size patch and while it avoids the warning in the reported test case it's not effective in others derived from it, such as: #include <string> const char constantString[] = {42, 53}; void f(std::string& s, int n) { if (n < 2) n = 2; s.insert(0, static_cast<const char*>(constantString), n); }