* build error --std=c++17 vs --std=c++23 -Wrestrict "may overlap up to 9223372036854775813 bytes at offset -3"
@ 2023-02-11 23:38 Jonny Grant
2023-02-12 0:14 ` Jonny Grant
2023-02-12 1:33 ` Jonathan Wakely
0 siblings, 2 replies; 7+ messages in thread
From: Jonny Grant @ 2023-02-11 23:38 UTC (permalink / raw)
To: gcc-help
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));
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: build error --std=c++17 vs --std=c++23 -Wrestrict "may overlap up to 9223372036854775813 bytes at offset -3"
2023-02-11 23:38 build error --std=c++17 vs --std=c++23 -Wrestrict "may overlap up to 9223372036854775813 bytes at offset -3" Jonny Grant
@ 2023-02-12 0:14 ` Jonny Grant
2023-02-12 1:33 ` Jonathan Wakely
1 sibling, 0 replies; 7+ messages in thread
From: Jonny Grant @ 2023-02-12 0:14 UTC (permalink / raw)
To: gcc-help
I saw there are quite a few similar issues reported.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=Wrestrict
Maybe it is similar to this one
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105651
Jonny
On 11/02/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=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));
> | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: build error --std=c++17 vs --std=c++23 -Wrestrict "may overlap up to 9223372036854775813 bytes at offset -3"
2023-02-11 23:38 build error --std=c++17 vs --std=c++23 -Wrestrict "may overlap up to 9223372036854775813 bytes at offset -3" Jonny Grant
2023-02-12 0:14 ` Jonny Grant
@ 2023-02-12 1:33 ` Jonathan Wakely
2023-02-12 11:20 ` Jonny Grant
1 sibling, 1 reply; 7+ messages in thread
From: Jonathan Wakely @ 2023-02-12 1:33 UTC (permalink / raw)
To: Jonny Grant; +Cc: gcc-help
[-- Attachment #1: Type: text/plain, Size: 2914 bytes --]
On Sat, 11 Feb 2023, 23:38 Jonny Grant, <jg@jguk.org> 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=c++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 <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));
> |
> ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: build error --std=c++17 vs --std=c++23 -Wrestrict "may overlap up to 9223372036854775813 bytes at offset -3"
2023-02-12 1:33 ` Jonathan Wakely
@ 2023-02-12 11:20 ` Jonny Grant
0 siblings, 0 replies; 7+ messages in thread
From: Jonny Grant @ 2023-02-12 11:20 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: gcc-help
On 12/02/2023 01:33, Jonathan Wakely wrote:
>
>
> On Sat, 11 Feb 2023, 23:38 Jonny Grant, <jg@jguk.org <mailto:jg@jguk.org>> 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=c++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.
Ok I see.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: build error --std=c++17 vs --std=c++23 -Wrestrict "may overlap up to 9223372036854775813 bytes at offset -3"
2023-02-23 16:32 ` Jonathan Wakely
@ 2023-02-23 17:47 ` Saifi Khan
0 siblings, 0 replies; 7+ messages in thread
From: Saifi Khan @ 2023-02-23 17:47 UTC (permalink / raw)
To: gcc-help
> -------Original Message-------
> From: Jonathan Wakely via Gcc-help <gcc-help@gcc.gnu.org>
> To: Saifi Khan <saifi.khan@nishan.io>
> Cc: gcc-help@gcc.gnu.org <gcc-help@gcc.gnu.org>
> Subject: Re: build error --std=c++17 vs --std=c++23 -Wrestrict "may overlap up to 9223372036854775813 bytes at offset -3"
> Sent: 2023-02-23 16:33
>
> On Thu, 23 Feb 2023 at 14:10, Saifi Khan wrote:
> >
> > Hi:
> >
> > Tried Jonny Grant's example
> > g++ -O3 --std=c++23 -Wall -c repro_jg01.cc
>
> Context please - which example is that?
#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";
}
Here is a verbatim copy of the the sample code, in which the OP encountered build error(s) with gcc 12.2.x
warm regards
Saifi.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: build error --std=c++17 vs --std=c++23 -Wrestrict "may overlap up to 9223372036854775813 bytes at offset -3"
2023-02-23 14:09 Saifi Khan
@ 2023-02-23 16:32 ` Jonathan Wakely
2023-02-23 17:47 ` Saifi Khan
0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Wakely @ 2023-02-23 16:32 UTC (permalink / raw)
To: Saifi Khan; +Cc: gcc-help
On Thu, 23 Feb 2023 at 14:10, Saifi Khan wrote:
>
> Hi:
>
> Tried Jonny Grant's example
> g++ -O3 --std=c++23 -Wall -c repro_jg01.cc
Context please - which example is that? He's posted several and I'm
not going to go digging through them all.
>
> With the mainline build, the code compiles without any error.
>
> Environment
> - Linux 6.1.0-3-amd64 x86_64 GNU/Linux
> - Debian GLIBC 2.36-8) 2.36
> - gcc version 13.0.1 20230215 (experimental) (GCC)
>
> Curious to know, what changed in the mainline code ? Anyone knows the commit hash ?
If you don't tell us what you're compiling, we can't guess anything about it.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: build error --std=c++17 vs --std=c++23 -Wrestrict "may overlap up to 9223372036854775813 bytes at offset -3"
@ 2023-02-23 14:09 Saifi Khan
2023-02-23 16:32 ` Jonathan Wakely
0 siblings, 1 reply; 7+ messages in thread
From: Saifi Khan @ 2023-02-23 14:09 UTC (permalink / raw)
To: gcc-help
Hi:
Tried Jonny Grant's example
g++ -O3 --std=c++23 -Wall -c repro_jg01.cc
With the mainline build, the code compiles without any error.
Environment
- Linux 6.1.0-3-amd64 x86_64 GNU/Linux
- Debian GLIBC 2.36-8) 2.36
- gcc version 13.0.1 20230215 (experimental) (GCC)
Curious to know, what changed in the mainline code ? Anyone knows the commit hash ?
warm regards
Saifi.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-02-23 17:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-11 23:38 build error --std=c++17 vs --std=c++23 -Wrestrict "may overlap up to 9223372036854775813 bytes at offset -3" Jonny Grant
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
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).