public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug pch/106799] New: `forming offset [32, 36] is out of the bounds` error with precompiled headers
@ 2022-09-01  8:47 michal at sawicz dot net
  2022-09-01  9:27 ` [Bug pch/106799] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: michal at sawicz dot net @ 2022-09-01  8:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106799

            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=53527&action=edit
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=c++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=c++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,                               
                 from /usr/include/c++/12/ostream:38,                           
                 from /usr/include/c++/12/bits/unique_ptr.h:41,                 
                 from /usr/include/c++/12/memory:76,                            
                 from
/usr/src/googletest/googlemock/include/gmock/gmock-actions.h:139,               
                 from /usr/src/googletest/googlemock/include/gmock/gmock.h:56,  
                 from ./cmake_pch.hxx:5,                                        
                 from <command-line>:                                           
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 ‘constexpr std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::basic_string(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:675:23,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits,
_Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits,
_Allocator>&&, const _CharT*) [with _CharT = char; _Traits = char
_traits<char>; _Alloc = allocator<char>]’ at
/usr/include/c++/12/bits/basic_string.h:3555:43,
    inlined from ‘testing::internal::TypedExpectation<F>&
testing::internal::MockSpec<F>::InternalExpectedAt(const char*, int, const
char*, const char*) [with F = void(bool)]’ at /usr/src/googletest/goog
lemock/include/gmock/gmock-spec-builders.h:1278:23,                             
    inlined from ‘virtual void Test_tests_Test::TestBody()’ at tmp.cpp:20:5:    
/usr/include/c++/12/bits/char_traits.h:431:56: warning: ‘void*
__builtin_memcpy(void*, const void*, long unsigned int)’ writing 19 bytes into
a region of size 16 overflows the destination [-Wstringop-ove
rflow=]                                                                         
  431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2,
__n));
      |                                       
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~                     
In file included from
/usr/src/googletest/googlemock/include/gmock/gmock-function-mocker.h:43,       
                 from /usr/src/googletest/googlemock/include/gmock/gmock.h:58:  
/usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h: In member
function ‘virtual void Test_tests_Test::TestBody()’:
/usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h:1278:63:
note: at offset 16 into destination object ‘<anonymous>’ of size 32
 1278 |     const std::string source_text(std::string("EXPECT_CALL(") + obj +
", " +                                                                         
                                                   |                           
            ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
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 ‘constexpr std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::basic_string(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:675:23,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits,
_Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits,
_Allocator>&&, const _CharT*) [with _CharT = char; _Traits = char
_traits<char>; _Alloc = allocator<char>]’ at
/usr/include/c++/12/bits/basic_string.h:3555:43,
    inlined from ‘testing::internal::TypedExpectation<F>&
testing::internal::MockSpec<F>::InternalExpectedAt(const char*, int, const
char*, const char*) [with F = void(bool)]’ at /usr/src/googletest/goog
lemock/include/gmock/gmock-spec-builders.h:1278:23,
    inlined from ‘virtual void Test_tests_Test::TestBody()’ at tmp.cpp:20:5:
/usr/include/c++/12/bits/char_traits.h:431:56: warning: ‘void*
__builtin_memcpy(void*, const void*, long unsigned int)’ writing 21 bytes into
a region of size 16 overflows the destination [-Wstringop-ove
rflow=]
  431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2,
__n));
      |                                       
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h: In member
function ‘virtual void Test_tests_Test::TestBody()’:
/usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h:1278:69:
note: at offset 16 into destination object ‘<anonymous>’ of size 32
 1278 |     const std::string source_text(std::string("EXPECT_CALL(") + obj +
", " +
      |                                       
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
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 ‘constexpr std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::basic_string(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:675:23,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits,
_Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits,
_Allocator>&&, const _CharT*) [with _CharT = char; _Traits = char
_traits<char>; _Alloc = allocator<char>]’ at
/usr/include/c++/12/bits/basic_string.h:3555:43,
    inlined from ‘testing::internal::TypedExpectation<F>&
testing::internal::MockSpec<F>::InternalExpectedAt(const char*, int, const
char*, const char*) [with F = void(bool)]’ at /usr/src/googletest/goog
lemock/include/gmock/gmock-spec-builders.h:1278:23,
    inlined from ‘virtual void Test_tests_Test::TestBody()’ at tmp.cpp:20:5:
/usr/include/c++/12/bits/char_traits.h:431:56: warning: ‘void*
__builtin_memcpy(void*, const void*, long unsigned int)’ writing 39 bytes into
a region of size 16 overflows the destination [-Wstringop-ove
rflow=]
  431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2,
__n));
      |                                       
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h: In member
function ‘virtual void Test_tests_Test::TestBody()’:
/usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h:1278:76:
note: at offset 16 into destination object ‘<anonymous>’ of size 32
 1278 |     const std::string source_text(std::string("EXPECT_CALL(") + obj +
", " +
      |                                       
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
 1279 |                                   call + ")");
      |                                   ~~~~
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 ‘constexpr std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::basic_string(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:675:23,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits,
_Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits,
_Allocator>&&, const _CharT*) [with _CharT = char; _Traits = char
_traits<char>; _Alloc = allocator<char>]’ at
/usr/include/c++/12/bits/basic_string.h:3555:43,
    inlined from ‘testing::internal::TypedExpectation<F>&
testing::internal::MockSpec<F>::InternalExpectedAt(const char*, int, const
char*, const char*) [with F = void(bool)]’ at /usr/src/googletest/goog
lemock/include/gmock/gmock-spec-builders.h:1278:23,
    inlined from ‘virtual void Test_tests_Test::TestBody()’ at tmp.cpp:20:5:
/usr/include/c++/12/bits/char_traits.h:431:56: warning: ‘void*
__builtin_memcpy(void*, const void*, long unsigned int)’ writing 40 bytes into
a region of size 16 overflows the destination [-Wstringop-ove
rflow=]
  431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2,
__n));
      |                                       
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h: In member
function ‘virtual void Test_tests_Test::TestBody()’:
/usr/src/googletest/googlemock/include/gmock/gmock-spec-builders.h:1278:23:
note: at offset 16 into destination object ‘source_text’ of size 32
 1278 |     const std::string source_text(std::string("EXPECT_CALL(") + obj +
", " +
      |                       ^~~~~~~~~~~
```

gcc-11 continues to work.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug pch/106799] `forming offset [32, 36] is out of the bounds` error with precompiled headers
  2022-09-01  8:47 [Bug pch/106799] New: `forming offset [32, 36] is out of the bounds` error with precompiled headers michal at sawicz dot net
@ 2022-09-01  9:27 ` rguenth at gcc dot gnu.org
  2022-09-01  9:57 ` michal at sawicz dot net
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-09-01  9:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106799

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
You say that without using a PCH it doesn't warn?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug pch/106799] `forming offset [32, 36] is out of the bounds` error with precompiled headers
  2022-09-01  8:47 [Bug pch/106799] New: `forming offset [32, 36] is out of the bounds` error with precompiled headers michal at sawicz dot net
  2022-09-01  9:27 ` [Bug pch/106799] " rguenth at gcc dot gnu.org
@ 2022-09-01  9:57 ` michal at sawicz dot net
  2022-10-22  0:24 ` [Bug middle-end/106799] " pinskia at gcc dot gnu.org
  2022-10-22 12:27 ` michal at sawicz dot net
  3 siblings, 0 replies; 5+ messages in thread
From: michal at sawicz dot net @ 2022-09-01  9:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106799

--- Comment #2 from michal at sawicz dot net ---
@Richard correct, if you skip the precompilation, it compiles fine:

```
$ rm cmake_pch.hxx.gch
$ /usr/bin/g++-12 -I/usr/src/googletest/googlemock/include -O2 -std=c++20
-include cmake_pch.hxx -c tmp.cpp
$
```

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/106799] `forming offset [32, 36] is out of the bounds` error with precompiled headers
  2022-09-01  8:47 [Bug pch/106799] New: `forming offset [32, 36] is out of the bounds` error with precompiled headers michal at sawicz dot net
  2022-09-01  9:27 ` [Bug pch/106799] " rguenth at gcc dot gnu.org
  2022-09-01  9:57 ` michal at sawicz dot net
@ 2022-10-22  0:24 ` pinskia at gcc dot gnu.org
  2022-10-22 12:27 ` michal at sawicz dot net
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-22  0:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106799

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2022-10-22

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Can you attach the preprocessed source for the cmake_pch.hxx file?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/106799] `forming offset [32, 36] is out of the bounds` error with precompiled headers
  2022-09-01  8:47 [Bug pch/106799] New: `forming offset [32, 36] is out of the bounds` error with precompiled headers michal at sawicz dot net
                   ` (2 preceding siblings ...)
  2022-10-22  0:24 ` [Bug middle-end/106799] " pinskia at gcc dot gnu.org
@ 2022-10-22 12:27 ` michal at sawicz dot net
  3 siblings, 0 replies; 5+ messages in thread
From: michal at sawicz dot net @ 2022-10-22 12:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106799

--- Comment #4 from michal at sawicz dot net ---
Created attachment 53756
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53756&action=edit
Preprocessed header source

I believe that should be it.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-22 12:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-01  8:47 [Bug pch/106799] New: `forming offset [32, 36] is out of the bounds` error with precompiled headers michal at sawicz dot net
2022-09-01  9:27 ` [Bug pch/106799] " rguenth at gcc dot gnu.org
2022-09-01  9:57 ` michal at sawicz dot net
2022-10-22  0:24 ` [Bug middle-end/106799] " pinskia at gcc dot gnu.org
2022-10-22 12:27 ` michal at sawicz dot net

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).