From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0DE2C38582AD; Thu, 1 Sep 2022 08:47:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0DE2C38582AD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662022068; bh=EAWsSSLJz1L+LdVwsZJI1oRvvRm0Ho2xiaxiEYTiNmw=; h=From:To:Subject:Date:From; b=bvkhvUtGoOO6OamcR/atww3OofnEWZdSda2eYzYslRyx4Z0Orv+KhNDtmeqAVvNXQ uwvn+4xO/Ag/FwyZhE5e4CwJZaQYH1OQ7a7o3NK/eHn3ysmglgy1alDPxb7DvaZ+dC e/U8qPs4qfjIopP8T5deiIhprYOXYZ8uNhZWT+0o= From: "michal at sawicz dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug pch/106799] New: `forming offset [32, 36] is out of the bounds` error with precompiled headers Date: Thu, 01 Sep 2022 08:47:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: pch X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: michal at sawicz dot net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_file_loc bug_status bug_severity priority component assigned_to reporter target_milestone cf_gcchost cf_gcctarget cf_gccbuild attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106799 Bug ID: 106799 Summary: `forming offset [32, 36] is out of the bounds` error with precompiled headers Product: gcc Version: 12.2.0 URL: https://bugs.launchpad.net/ubuntu/+source/gcc-12/+bug/ 1983852 Status: UNCONFIRMED Severity: normal Priority: P3 Component: pch Assignee: unassigned at gcc dot gnu.org Reporter: michal at sawicz dot net Target Milestone: --- Host: x86_64 Target: x86_64 Build: x86_64 Created attachment 53527 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D53527&action=3Dedit Header and source files needed to reproduce NB: googletest required to reproduce. Given the three minimal source files and the commands: ``` /usr/bin/g++-12 -I/usr/src/googletest/googlemock/include -O2 -std=3Dc++20 -include cmake_pch.hxx -include cmake_pch.hxx -x c++-header -o cmake_pch.hxx.gch -c cmake_pch.hxx.cxx /usr/bin/g++-12 -I/usr/src/googletest/googlemock/include -O2 -std=3Dc++20 -include cmake_pch.hxx -c tmp.cpp ``` gcc-12 errors out with the following: ``` In file included from /usr/include/c++/12/ios:40,=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 from /usr/include/c++/12/ostream:38,=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 from /usr/include/c++/12/bits/unique_ptr.h:41,=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20 from /usr/include/c++/12/memory:76,=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 from /usr/src/googletest/googlemock/include/gmock/gmock-actions.h:139,=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 from /usr/src/googletest/googlemock/include/gmock/gmock.h:= 56,=20=20 from ./cmake_pch.hxx:5,=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20 from :=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20 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=98constexpr std::__cxx11::basic_string<_CharT, _Tra= its, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [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:675:23, inlined from =E2=80=98constexpr std::__cxx11::basic_string<_CharT, _Tra= its, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*) [with _CharT =3D char; _Traits =3D char _traits; _Alloc =3D allocator]=E2=80=99 at /usr/include/c++/12/bits/basic_string.h:3555:43, inlined from =E2=80=98testing::internal::TypedExpectation& testing::internal::MockSpec::InternalExpectedAt(const char*, int, const char*, const char*) [with F =3D void(bool)]=E2=80=99 at /usr/src/googletest= /goog lemock/include/gmock/gmock-spec-builders.h:1278:23,=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 inlined from =E2=80=98virtual void Test_tests_Test::TestBody()=E2=80=99= at tmp.cpp:20:5:=20=20=20=20 /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 writing 19= bytes into a region of size 16 overflows the destination [-Wstringop-ove rflow=3D]=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20 431 | return static_cast(__builtin_memcpy(__s1, __s2, __n)); |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20 In file included from /usr/src/googletest/googlemock/include/gmock/gmock-function-mocker.h:43,=20= =20=20=20=20=20=20 from /usr/src/googletest/googlemock/include/gmock/gmock.h:= 58:=20=20 /usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h: In memb= er function =E2=80=98virtual void Test_tests_Test::TestBody()=E2=80=99: /usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h:1278:63: note: at offset 16 into destination object =E2=80=98=E2=80=99 of= size 32 1278 | const std::string source_text(std::string("EXPECT_CALL(") + obj= + ", " +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 |=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ~~~~~~~~~~~~~~~~~~~~~~~^~~~~ 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,=20=20=20=20=20=20=20 inlined from =E2=80=98constexpr std::__cxx11::basic_string<_CharT, _Tra= its, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [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:675:23, inlined from =E2=80=98constexpr std::__cxx11::basic_string<_CharT, _Tra= its, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*) [with _CharT =3D char; _Traits =3D char _traits; _Alloc =3D allocator]=E2=80=99 at /usr/include/c++/12/bits/basic_string.h:3555:43, inlined from =E2=80=98testing::internal::TypedExpectation& testing::internal::MockSpec::InternalExpectedAt(const char*, int, const char*, const char*) [with F =3D void(bool)]=E2=80=99 at /usr/src/googletest= /goog lemock/include/gmock/gmock-spec-builders.h:1278:23, inlined from =E2=80=98virtual void Test_tests_Test::TestBody()=E2=80=99= at tmp.cpp:20:5: /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 writing 21= bytes into a region of size 16 overflows the destination [-Wstringop-ove rflow=3D] 431 | return static_cast(__builtin_memcpy(__s1, __s2, __n)); |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h: In memb= er function =E2=80=98virtual void Test_tests_Test::TestBody()=E2=80=99: /usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h:1278:69: note: at offset 16 into destination object =E2=80=98=E2=80=99 of= size 32 1278 | const std::string source_text(std::string("EXPECT_CALL(") + obj= + ", " + |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ 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=98constexpr std::__cxx11::basic_string<_CharT, _Tra= its, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [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:675:23, inlined from =E2=80=98constexpr std::__cxx11::basic_string<_CharT, _Tra= its, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*) [with _CharT =3D char; _Traits =3D char _traits; _Alloc =3D allocator]=E2=80=99 at /usr/include/c++/12/bits/basic_string.h:3555:43, inlined from =E2=80=98testing::internal::TypedExpectation& testing::internal::MockSpec::InternalExpectedAt(const char*, int, const char*, const char*) [with F =3D void(bool)]=E2=80=99 at /usr/src/googletest= /goog lemock/include/gmock/gmock-spec-builders.h:1278:23, inlined from =E2=80=98virtual void Test_tests_Test::TestBody()=E2=80=99= at tmp.cpp:20:5: /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 writing 39= bytes into a region of size 16 overflows the destination [-Wstringop-ove rflow=3D] 431 | return static_cast(__builtin_memcpy(__s1, __s2, __n)); |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h: In memb= er function =E2=80=98virtual void Test_tests_Test::TestBody()=E2=80=99: /usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h:1278:76: note: at offset 16 into destination object =E2=80=98=E2=80=99 of= size 32 1278 | const std::string source_text(std::string("EXPECT_CALL(") + obj= + ", " + |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 1279 | call + ")"); | ~~~~ 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=98constexpr std::__cxx11::basic_string<_CharT, _Tra= its, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [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:675:23, inlined from =E2=80=98constexpr std::__cxx11::basic_string<_CharT, _Tra= its, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*) [with _CharT =3D char; _Traits =3D char _traits; _Alloc =3D allocator]=E2=80=99 at /usr/include/c++/12/bits/basic_string.h:3555:43, inlined from =E2=80=98testing::internal::TypedExpectation& testing::internal::MockSpec::InternalExpectedAt(const char*, int, const char*, const char*) [with F =3D void(bool)]=E2=80=99 at /usr/src/googletest= /goog lemock/include/gmock/gmock-spec-builders.h:1278:23, inlined from =E2=80=98virtual void Test_tests_Test::TestBody()=E2=80=99= at tmp.cpp:20:5: /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 writing 40= bytes into a region of size 16 overflows the destination [-Wstringop-ove rflow=3D] 431 | return static_cast(__builtin_memcpy(__s1, __s2, __n)); |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h: In memb= er function =E2=80=98virtual void Test_tests_Test::TestBody()=E2=80=99: /usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h:1278:23: note: at offset 16 into destination object =E2=80=98source_text=E2=80=99 of= size 32 1278 | const std::string source_text(std::string("EXPECT_CALL(") + obj= + ", " + | ^~~~~~~~~~~ ``` gcc-11 continues to work.=