public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105545] New: Compiling string assignment with _GLIBCXX_ASSERTIONS defined fails in 12.1.0, works in 11.1.0
@ 2022-05-10 11:15 jvb at cyberscience dot com
  2022-05-10 11:18 ` [Bug c++/105545] [12/13 Regression] Compiling string assignment with _GLIBCXX_ASSERTIONS fails since r12-3347-g8af8abfbbace49e6 marxin at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: jvb at cyberscience dot com @ 2022-05-10 11:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105545
           Summary: Compiling string assignment with _GLIBCXX_ASSERTIONS
                    defined fails in 12.1.0, works in 11.1.0
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jvb at cyberscience dot com
  Target Milestone: ---

Compiling using -D_GLIBCXX_ASSERTIONS fails in gcc 12.1.0, worked in 11.1.0:

  #include <string>
  extern std::string a();

  std::string a()
  {
    std::string x;
    x.assign( "Z" );
    return x;
  }

using command line:

   g++ -m64 -c -std=gnu++17 -Wall -O3 -Werror -D_GLIBCXX_ASSERTIONS  x.cpp

fails with:

In file included from /usr/local/gcc-12.1.0/include/c++/12.1.0/string:40,
                 from x.cpp:14:
In static member function ??static std::char_traits<char>::char_type*
std::char_traits<char>::copy(char_type*, const char_type*, std::size_t)??,
    inlined from ??static 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/local/gcc-12.1.0/include/c++/12.1.0/bits/basic_string.h:423:21,
    inlined from ??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/local/gcc-12.1.0/include/c++/12.1.0/bits/basic_string.tcc:532:22,
    inlined from ??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/local/gcc-12.1.0/include/c++/12.1.0/bits/basic_string.h:1647:19,
    inlined from ??std::string a()?? at x.cpp:22:12:
/usr/local/gcc-12.1.0/include/c++/12.1.0/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 17
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

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

* [Bug c++/105545] [12/13 Regression] Compiling string assignment with _GLIBCXX_ASSERTIONS fails since r12-3347-g8af8abfbbace49e6
  2022-05-10 11:15 [Bug c++/105545] New: Compiling string assignment with _GLIBCXX_ASSERTIONS defined fails in 12.1.0, works in 11.1.0 jvb at cyberscience dot com
@ 2022-05-10 11:18 ` marxin at gcc dot gnu.org
  2022-05-10 12:26 ` [Bug c++/105545] [12/13 Regression] Warning for string assignment with _GLIBCXX_ASSERTIONS " redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-05-10 11:18 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.2
   Last reconfirmed|                            |2022-05-10
                 CC|                            |aldyh at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org
            Summary|Compiling string assignment |[12/13 Regression]
                   |with _GLIBCXX_ASSERTIONS    |Compiling string assignment
                   |defined fails in 12.1.0,    |with _GLIBCXX_ASSERTIONS
                   |works in 11.1.0             |fails since
                   |                            |r12-3347-g8af8abfbbace49e6
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r12-3347-g8af8abfbbace49e6.

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

* [Bug c++/105545] [12/13 Regression] Warning for string assignment with _GLIBCXX_ASSERTIONS since r12-3347-g8af8abfbbace49e6
  2022-05-10 11:15 [Bug c++/105545] New: Compiling string assignment with _GLIBCXX_ASSERTIONS defined fails in 12.1.0, works in 11.1.0 jvb at cyberscience dot com
  2022-05-10 11:18 ` [Bug c++/105545] [12/13 Regression] Compiling string assignment with _GLIBCXX_ASSERTIONS fails since r12-3347-g8af8abfbbace49e6 marxin at gcc dot gnu.org
@ 2022-05-10 12:26 ` redi at gcc dot gnu.org
  2022-05-11  7:19 ` [Bug tree-optimization/105545] " rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-05-10 12:26 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[12/13 Regression]          |[12/13 Regression] Warning
                   |Compiling string assignment |for string assignment with
                   |with _GLIBCXX_ASSERTIONS    |_GLIBCXX_ASSERTIONS since
                   |fails since                 |r12-3347-g8af8abfbbace49e6
                   |r12-3347-g8af8abfbbace49e6  |
           Keywords|                            |diagnostic

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to John Buddery from comment #0)
>    g++ -m64 -c -std=gnu++17 -Wall -O3 -Werror -D_GLIBCXX_ASSERTIONS  x.cpp


This is only a warning. It fails because you asked it to, with -Werror.

Reporting that compilation fails when you turn warnings into errors isn't very
interesting, that's the point of -Werror :-)

So the bug here is a bogus warning, not that compilation fails. Summary
adjusted accordingly.

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

* [Bug tree-optimization/105545] [12/13 Regression] Warning for string assignment with _GLIBCXX_ASSERTIONS since r12-3347-g8af8abfbbace49e6
  2022-05-10 11:15 [Bug c++/105545] New: Compiling string assignment with _GLIBCXX_ASSERTIONS defined fails in 12.1.0, works in 11.1.0 jvb at cyberscience dot com
  2022-05-10 11:18 ` [Bug c++/105545] [12/13 Regression] Compiling string assignment with _GLIBCXX_ASSERTIONS fails since r12-3347-g8af8abfbbace49e6 marxin at gcc dot gnu.org
  2022-05-10 12:26 ` [Bug c++/105545] [12/13 Regression] Warning for string assignment with _GLIBCXX_ASSERTIONS " redi at gcc dot gnu.org
@ 2022-05-11  7:19 ` rguenth at gcc dot gnu.org
  2022-05-12 15:17 ` ed at catmur dot uk
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-11  7:19 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug tree-optimization/105545] [12/13 Regression] Warning for string assignment with _GLIBCXX_ASSERTIONS since r12-3347-g8af8abfbbace49e6
  2022-05-10 11:15 [Bug c++/105545] New: Compiling string assignment with _GLIBCXX_ASSERTIONS defined fails in 12.1.0, works in 11.1.0 jvb at cyberscience dot com
                   ` (2 preceding siblings ...)
  2022-05-11  7:19 ` [Bug tree-optimization/105545] " rguenth at gcc dot gnu.org
@ 2022-05-12 15:17 ` ed at catmur dot uk
  2022-05-12 15:51 ` tom at compton dot nu
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ed at catmur dot uk @ 2022-05-12 15:17 UTC (permalink / raw)
  To: gcc-bugs

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

Ed Catmur <ed at catmur dot uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ed at catmur dot uk

--- Comment #3 from Ed Catmur <ed at catmur dot uk> ---
I don't think _GLIBCXX_ASSERTIONS is necessary; you just need -Werror=restrict
and -O2 (not sure what exactly). https://godbolt.org/z/TvfYzbcf6

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

* [Bug tree-optimization/105545] [12/13 Regression] Warning for string assignment with _GLIBCXX_ASSERTIONS since r12-3347-g8af8abfbbace49e6
  2022-05-10 11:15 [Bug c++/105545] New: Compiling string assignment with _GLIBCXX_ASSERTIONS defined fails in 12.1.0, works in 11.1.0 jvb at cyberscience dot com
                   ` (3 preceding siblings ...)
  2022-05-12 15:17 ` ed at catmur dot uk
@ 2022-05-12 15:51 ` tom at compton dot nu
  2022-05-12 16:00 ` tom at compton dot nu
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tom at compton dot nu @ 2022-05-12 15:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Tom Hughes <tom at compton dot nu> ---
You don't need -D_GLIBCXX_ASSERTIONS in C++20 mode but you do in C++17 mode it
seems.

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

* [Bug tree-optimization/105545] [12/13 Regression] Warning for string assignment with _GLIBCXX_ASSERTIONS since r12-3347-g8af8abfbbace49e6
  2022-05-10 11:15 [Bug c++/105545] New: Compiling string assignment with _GLIBCXX_ASSERTIONS defined fails in 12.1.0, works in 11.1.0 jvb at cyberscience dot com
                   ` (4 preceding siblings ...)
  2022-05-12 15:51 ` tom at compton dot nu
@ 2022-05-12 16:00 ` tom at compton dot nu
  2022-05-31  7:33 ` tom at compton dot nu
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tom at compton dot nu @ 2022-05-12 16:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Tom Hughes <tom at compton dot nu> ---
On top of -O1 you seem to need all of -fexpensive-optimizations -ftree-vrp
-fipa-sra to trigger it.

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

* [Bug tree-optimization/105545] [12/13 Regression] Warning for string assignment with _GLIBCXX_ASSERTIONS since r12-3347-g8af8abfbbace49e6
  2022-05-10 11:15 [Bug c++/105545] New: Compiling string assignment with _GLIBCXX_ASSERTIONS defined fails in 12.1.0, works in 11.1.0 jvb at cyberscience dot com
                   ` (5 preceding siblings ...)
  2022-05-12 16:00 ` tom at compton dot nu
@ 2022-05-31  7:33 ` tom at compton dot nu
  2022-06-21 15:35 ` pdimov at gmail dot com
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tom at compton dot nu @ 2022-05-31  7:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Tom Hughes <tom at compton dot nu> ---
The reason it only happens with -D_GLIBCXX_ASSERTIONS or in C++20 mode is that
both of those stop the use of the explicit instantiations for basic_string and
cause them to be implicitly instantiated.

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

* [Bug tree-optimization/105545] [12/13 Regression] Warning for string assignment with _GLIBCXX_ASSERTIONS since r12-3347-g8af8abfbbace49e6
  2022-05-10 11:15 [Bug c++/105545] New: Compiling string assignment with _GLIBCXX_ASSERTIONS defined fails in 12.1.0, works in 11.1.0 jvb at cyberscience dot com
                   ` (6 preceding siblings ...)
  2022-05-31  7:33 ` tom at compton dot nu
@ 2022-06-21 15:35 ` pdimov at gmail dot com
  2022-11-03 18:07 ` pdimov at gmail dot com
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pdimov at gmail dot com @ 2022-06-21 15:35 UTC (permalink / raw)
  To: gcc-bugs

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

Peter Dimov <pdimov at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pdimov at gmail dot com

--- Comment #7 from Peter Dimov <pdimov at gmail dot com> ---
FWIW, I'm getting this warning in one of the Boost.Describe examples
(https://godbolt.org/z/WKMjeTdne) from innocent-looking code that concatenates
std::strings with op+.

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

* [Bug tree-optimization/105545] [12/13 Regression] Warning for string assignment with _GLIBCXX_ASSERTIONS since r12-3347-g8af8abfbbace49e6
  2022-05-10 11:15 [Bug c++/105545] New: Compiling string assignment with _GLIBCXX_ASSERTIONS defined fails in 12.1.0, works in 11.1.0 jvb at cyberscience dot com
                   ` (7 preceding siblings ...)
  2022-06-21 15:35 ` pdimov at gmail dot com
@ 2022-11-03 18:07 ` pdimov at gmail dot com
  2023-04-17 16:39 ` [Bug tree-optimization/105545] [12/13/14 " jvb at cyberscience dot com
  2023-04-20 12:00 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: pdimov at gmail dot com @ 2022-11-03 18:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Peter Dimov <pdimov at gmail dot com> ---
My Godbolt link above no longer reproduces the warning because of
https://github.com/boostorg/describe/commit/c8c46bfdf78022a8a7e9e06983d8b04ccb921991,
but this one does: https://godbolt.org/z/oT1M31osa.

Looks like trunk has fixed the issue, though: https://godbolt.org/z/1GGvYWxKG.

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

* [Bug tree-optimization/105545] [12/13/14 Regression] Warning for string assignment with _GLIBCXX_ASSERTIONS since r12-3347-g8af8abfbbace49e6
  2022-05-10 11:15 [Bug c++/105545] New: Compiling string assignment with _GLIBCXX_ASSERTIONS defined fails in 12.1.0, works in 11.1.0 jvb at cyberscience dot com
                   ` (8 preceding siblings ...)
  2022-11-03 18:07 ` pdimov at gmail dot com
@ 2023-04-17 16:39 ` jvb at cyberscience dot com
  2023-04-20 12:00 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jvb at cyberscience dot com @ 2023-04-17 16:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from John Buddery <jvb at cyberscience dot com> ---
I can confirm this works on the gcc-13 branch, for both c++17 and c++20 - feel
free to close this issue.

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

* [Bug tree-optimization/105545] [12/13/14 Regression] Warning for string assignment with _GLIBCXX_ASSERTIONS since r12-3347-g8af8abfbbace49e6
  2022-05-10 11:15 [Bug c++/105545] New: Compiling string assignment with _GLIBCXX_ASSERTIONS defined fails in 12.1.0, works in 11.1.0 jvb at cyberscience dot com
                   ` (9 preceding siblings ...)
  2023-04-17 16:39 ` [Bug tree-optimization/105545] [12/13/14 " jvb at cyberscience dot com
@ 2023-04-20 12:00 ` redi at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2023-04-20 12:00 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It was fixed by r13-2618-g723ef5a937dbab so let's close this as a dup of PR
105651

*** This bug has been marked as a duplicate of bug 105651 ***

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

end of thread, other threads:[~2023-04-20 12:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 11:15 [Bug c++/105545] New: Compiling string assignment with _GLIBCXX_ASSERTIONS defined fails in 12.1.0, works in 11.1.0 jvb at cyberscience dot com
2022-05-10 11:18 ` [Bug c++/105545] [12/13 Regression] Compiling string assignment with _GLIBCXX_ASSERTIONS fails since r12-3347-g8af8abfbbace49e6 marxin at gcc dot gnu.org
2022-05-10 12:26 ` [Bug c++/105545] [12/13 Regression] Warning for string assignment with _GLIBCXX_ASSERTIONS " redi at gcc dot gnu.org
2022-05-11  7:19 ` [Bug tree-optimization/105545] " rguenth at gcc dot gnu.org
2022-05-12 15:17 ` ed at catmur dot uk
2022-05-12 15:51 ` tom at compton dot nu
2022-05-12 16:00 ` tom at compton dot nu
2022-05-31  7:33 ` tom at compton dot nu
2022-06-21 15:35 ` pdimov at gmail dot com
2022-11-03 18:07 ` pdimov at gmail dot com
2023-04-17 16:39 ` [Bug tree-optimization/105545] [12/13/14 " jvb at cyberscience dot com
2023-04-20 12:00 ` redi at gcc dot gnu.org

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