Activity log for bug #1990811

Date Who What changed Old value New value Message
2022-09-26 06:06:44 Chris Halse Rogers bug added bug
2022-09-26 06:06:44 Chris Halse Rogers attachment added Small testcase https://bugs.launchpad.net/bugs/1990811/+attachment/5618986/+files/gcc-bug-test.cpp
2022-09-26 06:08:59 Michał Sawicz bug added subscriber Michał Sawicz
2022-09-26 06:10:20 Michał Sawicz gcc-defaults (Ubuntu): status New Confirmed
2022-09-27 22:01:52 Olivier Gayot description The attached cpp file, when built with `g++ -O3 -S --std=c++20 -o test.o gcc-bug-test.cpp -Wall -Werror` on g++12, fails to compile with the following error. Notably, this error requires *both* --std=c++20 and -O3 - it compiles correctly at -O2, and it compiles correctly at -O3 with --std=c++17. In file included from /usr/include/c++/12/string:40, from gcc-bug-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 std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:1858:29, inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __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:3531:35, inlined from ‘std::string to_camel_case(const std::string&)’ at gcc-bug-test.cpp:6:45: /usr/include/c++/12/bits/char_traits.h:431:56: error: ‘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 [-Werror=restrict] 431 | return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n)); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors ProblemType: Bug DistroRelease: Ubuntu 22.10 Package: g++ 4:12.2.0-1ubuntu1 ProcVersionSignature: Ubuntu 5.19.0-15.15-generic 5.19.0 Uname: Linux 5.19.0-15-generic x86_64 NonfreeKernelModules: zfs zunicode zavl icp zcommon znvpair ApportVersion: 2.23.0-0ubuntu2 Architecture: amd64 CasperMD5CheckResult: pass Date: Mon Sep 26 16:02:09 2022 InstallationDate: Installed on 2021-06-26 (456 days ago) InstallationMedia: Ubuntu 21.10.0 2021.05.28 amd64 "bcachefs" (20210622) SourcePackage: gcc-defaults UpgradeStatus: Upgraded to kinetic on 2022-09-13 (13 days ago) The attached cpp file, when built with `g++ -O3 -S --std=c++20 -o test.o gcc-bug-test.cpp -Wall -Werror` on g++12, fails to compile with the following error. Notably, this error requires *both* --std=c++20 and -O3 - it compiles correctly at -O2, and it compiles correctly at -O3 with --std=c++17. In file included from /usr/include/c++/12/string:40,                  from gcc-bug-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 std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:1858:29,     inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __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:3531:35,     inlined from ‘std::string to_camel_case(const std::string&)’ at gcc-bug-test.cpp:6:45: /usr/include/c++/12/bits/char_traits.h:431:56: error: ‘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 [-Werror=restrict]   431 | return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));       | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors [[Testcase]] $ cat gcc-bug-test.cpp #include <string> std::string to_camel_case(std::string const& name) { std::string camel_cased_name; camel_cased_name = std::string{name[0]} + name.substr(1); return camel_cased_name; } $ g++ -O3 -S --std=c++20 -o test.o gcc-bug-test.cpp -Wall -Werror ProblemType: Bug DistroRelease: Ubuntu 22.10 Package: g++ 4:12.2.0-1ubuntu1 ProcVersionSignature: Ubuntu 5.19.0-15.15-generic 5.19.0 Uname: Linux 5.19.0-15-generic x86_64 NonfreeKernelModules: zfs zunicode zavl icp zcommon znvpair ApportVersion: 2.23.0-0ubuntu2 Architecture: amd64 CasperMD5CheckResult: pass Date: Mon Sep 26 16:02:09 2022 InstallationDate: Installed on 2021-06-26 (456 days ago) InstallationMedia: Ubuntu 21.10.0 2021.05.28 amd64 "bcachefs" (20210622) SourcePackage: gcc-defaults UpgradeStatus: Upgraded to kinetic on 2022-09-13 (13 days ago)
2022-09-28 07:37:43 Olivier Gayot summary Bogus -Wrestrict in builtin_memcpy from std::string & C++20 Bogus -Wrestrict in builtin_memcpy from std::string & C++20 on kinetic
2022-09-29 20:52:18 Dave Jones tags amd64 apport-bug kinetic third-party-packages wayland-session amd64 apport-bug foundations-todo kinetic third-party-packages wayland-session
2022-09-30 18:34:11 Nick Rosbrook gcc-defaults (Ubuntu): importance Undecided Low