public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonny Grant <jg@jguk.org>
To: gcc-help <gcc-help@gcc.gnu.org>
Subject: build error --std=c++17 vs --std=c++23 -Wrestrict "may overlap up to 9223372036854775813 bytes at offset -3"
Date: Sat, 11 Feb 2023 23:38:01 +0000	[thread overview]
Message-ID: <681c1224-aec4-9831-26b1-e11fd182dd5c@jguk.org> (raw)

Hello

Anyone else seeing an issue when using c++23 ?
gcc (Ubuntu 12.2.0-3ubuntu1) 12.2.0

The only change is to use --std=c++23

-Wrestrict is enabled by -Wall


#include <string>

typedef struct a_bc
{
    std::string a;
    std::string b;
} a_t;

void f()
{
    a_t c;

    c.a = " sdfsdf fsdfsdf fdfsfdsdf ";   // seems to need this long string to reproduce, down to 8 bytes it didn't
    c.b = "E";
}








$ g++ -O3 --std=c++23 -Wall -c -o gcc_err3 src/gcc_err3.cpp
In file included from /usr/include/c++/12/string:40,
                 from src/gcc_err3.cpp:4:
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>::assign(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:1647:19,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:815:28,
    inlined from ‘void f(const std::string&, bool, bool)’ at src/gcc_err3.cpp:17:13:
/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 -4611686018427387902 and [-4611686018427387903, 4611686018427387904] may overlap up to 9223372036854775813 bytes at offset -3 [-Wrestrict]
  431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
      |                                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~

             reply	other threads:[~2023-02-11 23:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-11 23:38 Jonny Grant [this message]
2023-02-12  0:14 ` Jonny Grant
2023-02-12  1:33 ` Jonathan Wakely
2023-02-12 11:20   ` Jonny Grant
2023-02-23 14:09 Saifi Khan
2023-02-23 16:32 ` Jonathan Wakely
2023-02-23 17:47   ` Saifi Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=681c1224-aec4-9831-26b1-e11fd182dd5c@jguk.org \
    --to=jg@jguk.org \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).