Bug 109563 - accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Wrestrict]
Summary: accessing 9223372036854775810 or more bytes at offsets [2, 922337203685477580...
Status: RESOLVED DUPLICATE of bug 105651
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 12.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wrestrict
  Show dependency treegraph
 
Reported: 2023-04-20 04:39 UTC by Frank Heckenbach
Modified: 2023-04-20 09:02 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Heckenbach 2023-04-20 04:39:51 UTC
I'd like to know if the warning is bogus or the library actually accesses invalid memory.

% cat test.cpp
#include <string>

void f (const std::string &s)
{
  "x" + std::string (s);
}
% g++ --std=c++20 -O3 -Wall -c test.cpp
In file included from /usr/include/c++/12/string:40,
                 from test.cpp:1:
In static member function ‘static constexpr std::char_traits<char>::char_type* std::char_traits<char>::copy(char_type*, const char_type*, std::size_t)’,
    inlined from ‘static constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_S_copy(_CharT*, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:423:21,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Allocator>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.tcc:532:22,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:2171:19,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:1928:22,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&) [with _CharT = char; _Traits = char_traits<char>; _Alloc = allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:3541:36,
    inlined from ‘void f(const std::string&)’ at test.cpp:5:7:
/usr/include/c++/12/bits/char_traits.h:431:56: warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Wrestrict]
  431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
      |
Comment 1 Andrew Pinski 2023-04-20 04:44:41 UTC
Dup of bug 105651.

*** This bug has been marked as a duplicate of bug 105651 ***
Comment 2 Frank Heckenbach 2023-04-20 04:49:50 UTC
Since I can't easily upgrade to trunk, I need to know if the warning is bogus in 12.2 and I can safely disable it, or do I need to worry about the generated code?
Comment 3 Richard Biener 2023-04-20 09:02:32 UTC
(In reply to Frank Heckenbach from comment #2)
> Since I can't easily upgrade to trunk, I need to know if the warning is
> bogus in 12.2 and I can safely disable it, or do I need to worry about the
> generated code?

the warning is bogus