From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 128A83858D32 for ; Sun, 12 Feb 2023 01:34:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 128A83858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x635.google.com with SMTP id dr8so24214158ejc.12 for ; Sat, 11 Feb 2023 17:34:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=K2Lc6Qay65XCFYkbCsk4+SbM3BKLVXEu+kRy8X/Vpk4=; b=nqFol+gzflq/xZAgW/B5A2LMa4zBSPHoWvxz6+SGt754xNBOVTGe17acRJ3WRedNG9 l5tMxH21UMWUEnwAW9OMfRDZjjH2O+K9r4iQ1DWvQ5xj5+VeOujcBU6KUq3nCWkZWEE6 QVeLzZdUwZdPrDBZ1EUhQwDRUk3ywEwdC2ZM5uSWnnYPK0aW2+OfqG7hZDgrv07PBC3D 93BO/wW+i+vfLpwWpvAzJ6B5f5EZb5qdNbdJ6ccvBHFzLOugzW+4sOJisL6E+epjMOHt nnmn998EkOJ14WpMoVoArz1Fu/IUZJlltWKeWq48Weva7FZRtpS1crFIx+Xa7vvburGo t0Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=K2Lc6Qay65XCFYkbCsk4+SbM3BKLVXEu+kRy8X/Vpk4=; b=ZK235DmfT1fGezISE9LVSev/ZnAZ1s+XTFQCsnBlNdi+8WGXQ9zVdasYefbKfvBn+e AcP42DxPWMkXK0oMWRQczSLumKKhZW0n3R6S42we/FNtfzD2UWo0MyKoczctHlAMlaM2 svxC3KsMXQ0AcHSUfPu/AoSU+eukjcGF3Tdx1jOlALxJC+9TnQzHGZT4x6iVVA65iPK1 fZ0lKuDNIwDLxEeTEdrt9RNlOk/8BBhbFoZAmUIW0r96yQvSu1dNUUwMpjgO60i6ESxa ETkgRVUZRWWxY0fx1d9eckK6ZiJIptUjCQSCq9Q9pXQBS5gt01CnP1503CNQ6t0sCHQV Dcdg== X-Gm-Message-State: AO0yUKVRPEy14xKz9mFW1pD6SUMnOz1uKRj1AfXvOJSu9NCUl7F0R2VD 0qsGI/v463BL4N3v3YI2X6TLFiwh1wkG4R8Rz8/yqSTB X-Google-Smtp-Source: AK7set+WuACi3lBUofchEwmRMez/8Ux2CkgcWDL7RsthzYZ4SaU2abL3WlGP1P0dvCob8lj+m44wrCyxOBIyUh6gMFo= X-Received: by 2002:a17:906:d28c:b0:8af:4963:fb08 with SMTP id ay12-20020a170906d28c00b008af4963fb08mr2084085ejb.15.1676165646583; Sat, 11 Feb 2023 17:34:06 -0800 (PST) MIME-Version: 1.0 References: <681c1224-aec4-9831-26b1-e11fd182dd5c@jguk.org> In-Reply-To: <681c1224-aec4-9831-26b1-e11fd182dd5c@jguk.org> From: Jonathan Wakely Date: Sun, 12 Feb 2023 01:33:53 +0000 Message-ID: Subject: Re: build error --std=c++17 vs --std=c++23 -Wrestrict "may overlap up to 9223372036854775813 bytes at offset -3" To: Jonny Grant Cc: gcc-help Content-Type: multipart/alternative; boundary="000000000000f30d2e05f476b966" X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,KAM_LINEPADDING,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000f30d2e05f476b966 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, 11 Feb 2023, 23:38 Jonny Grant, wrote: > 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=3Dc++23 > With C++17 std::string is instantiated in the library, not in your code. With C++20 your code instantiates it. That's the only reason the -std option matters here. > -Wrestrict is enabled by -Wall > > > #include > > typedef struct a_bc > { > std::string a; > std::string b; > } a_t; > > void f() > { > a_t c; > > c.a =3D " sdfsdf fsdfsdf fdfsfdsdf "; // seems to need this long > string to reproduce, down to 8 bytes it didn't > c.b =3D "E"; > } > > > > > > > > > $ g++ -O3 --std=3Dc++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 =E2=80=98static constexpr > std::char_traits::char_type* std::char_traits::copy(char_type= *, > const char_type*, std::size_t)=E2=80=99, > inlined from =E2=80=98static constexpr void std::__cxx11::basic_strin= g<_CharT, > _Traits, _Alloc>::_S_copy(_CharT*, const _CharT*, size_type) [with _CharT= =3D > char; _Traits =3D std::char_traits; _Alloc =3D std::allocator= ]=E2=80=99 at > /usr/include/c++/12/bits/basic_string.h:423:21, > inlined from =E2=80=98constexpr std::__cxx11::basic_string<_CharT, _T= raits, > _Allocator>& std::__cxx11::basic_string<_CharT, _Traits, > _Alloc>::_M_replace(size_type, size_type, const _CharT*, size_type) [with > _CharT =3D char; _Traits =3D std::char_traits; _Alloc =3D > std::allocator]=E2=80=99 at /usr/include/c++/12/bits/basic_string.t= cc:532:22, > inlined from =E2=80=98constexpr std::__cxx11::basic_string<_CharT, _T= raits, > _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(const > _CharT*) [with _CharT =3D char; _Traits =3D std::char_traits; _Allo= c =3D > std::allocator]=E2=80=99 at /usr/include/c++/12/bits/basic_string.h= :1647:19, > inlined from =E2=80=98constexpr std::__cxx11::basic_string<_CharT, _T= raits, > _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, > _Alloc>::operator=3D(const _CharT*) [with _CharT =3D char; _Traits =3D > std::char_traits; _Alloc =3D std::allocator]=E2=80=99 at > /usr/include/c++/12/bits/basic_string.h:815:28, > inlined from =E2=80=98void f(const std::string&, bool, bool)=E2=80=99= at > src/gcc_err3.cpp:17:13: > /usr/include/c++/12/bits/char_traits.h:431:56: warning: =E2=80=98void* > __builtin_memcpy(void*, const void*, long unsigned int)=E2=80=99 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(__builtin_memcpy(__s1, > __s2, __n)); > | > ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ > --000000000000f30d2e05f476b966--