[Bug c++/103534] [12 regression] Spurious -Wstringop-overflow warning with std::string concatencation

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Dec 2 21:03:21 GMT 2021


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
   Last reconfirmed|                            |2021-12-02
     Ever confirmed|0                           |1
             Blocks|                            |88443
                 CC|                            |msebor at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning is for the memcpy() call in BB 12 with _73 being in the reported
excessive range:

<bb 12> [local count: 172868773]:
_209 = D.41961._M_dataplus._M_p;
_103 = _69 + 16;
__builtin_memcpy (_103, _209, _73);   <<< 27->12  (T) _73 :     long unsigned
int [18446744073709551600, +INF]

The range comes from BB 27:

=========== BB 27 ============
Imports: _73  
Exports: _73  
_73     long unsigned int [0, 0][18446744073709551600, +INF]
__size_74       const long unsigned int [0, 16]
    <bb 27> [local count: 523844769]:
    if (_73 != 0)
      goto <bb 12>; [33.00%]
    else
      goto <bb 13>; [67.00%]

27->12  (T) _73 :       long unsigned int [18446744073709551600, +INF]
27->12  (T) __size_74 :         const long unsigned int [0, 15]
27->13  (F) _73 :       long unsigned int [0, 0]
27->13  (F) __size_74 :         const long unsigned int [16, 16]


The magic 16 most likely has to do with the small internal std::string buffer
that's 16 bytes big.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
[Bug 88443] [meta-bug] bogus/missing -Wstringop-overflow warnings


More information about the Gcc-bugs mailing list