public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20
@ 2022-05-18 23:38 mckelvey at maskull dot com
  2022-05-18 23:41 ` [Bug c++/105651] " mckelvey at maskull dot com
                   ` (26 more replies)
  0 siblings, 27 replies; 28+ messages in thread
From: mckelvey at maskull dot com @ 2022-05-18 23:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105651
           Summary: Failure compiling constexpr/__builtin_memcpy on Cygwin
                    with -std=c++20
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mckelvey at maskull dot com
  Target Milestone: ---

Created attachment 52990
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52990&action=edit
Build.log showing error

$ /usr/local/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/usr/local/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-cygwin/13.0.0/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: ./configure --enable-languages=c,c++ --enable-threads=posix
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20220515 (experimental) (GCC)

$ uname
CYGWIN_NT-10.0

Windows 10.

Builds on gcc-11,12,13 with -std=c++17, but all three fail with c++20.

In file included from /usr/local/include/c++/13.0.0/string:40,
                 from /usr/local/include/c++/13.0.0/bits/locale_classes.h:40,
                 from /usr/local/include/c++/13.0.0/locale:39,
                 from Types.h:36,
                 from PatternDriverTop.h:42,
                 from PatternDriverTop.cc:28:
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 void std::basic_string<_CharT, _Traits,
_Alloc>::_M_copy(_CharT*, const _CharT*, size_type) [with _CharT = char;
_Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at
/usr/local/include/c++/13.0.0/bits/cow_string.h:402:21,
    inlined from ‘std::basic_string<_CharT, _Traits, _Alloc>&
std::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const _CharT*,
size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>]’ at
/usr/local/include/c++/13.0.0/bits/cow_string.h:3297:16,
    inlined from ‘std::basic_string<_CharT, _Traits, _Alloc>&
std::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const _CharT*)
[with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>]’ at
/usr/local/include/c++/13.0.0/bits/cow_string.h:1609:21,
    inlined from ‘PatternDriver::pdstring
PatternDriver::_printable_by_ctype(const pdstring&, const std::locale&, const
pdctype&, bool, bool)’ at PatternDriverTop.cc:589:22:
/usr/local/include/c++/13.0.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 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

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

* [Bug c++/105651] Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
@ 2022-05-18 23:41 ` mckelvey at maskull dot com
  2022-05-19  0:10 ` [Bug tree-optimization/105651] bogus "may overlap" memcpy warning with std::string pinskia at gcc dot gnu.org
                   ` (25 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: mckelvey at maskull dot com @ 2022-05-18 23:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from James McKelvey <mckelvey at maskull dot com> ---
Created attachment 52991
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52991&action=edit
save-temps

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

* [Bug tree-optimization/105651] bogus "may overlap" memcpy warning with std::string
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
  2022-05-18 23:41 ` [Bug c++/105651] " mckelvey at maskull dot com
@ 2022-05-19  0:10 ` pinskia at gcc dot gnu.org
  2022-05-19  6:19 ` rguenth at gcc dot gnu.org
                   ` (24 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-19  0:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |tree-optimization
      Known to fail|                            |11.1.0, 12.1.0, 13.0
            Summary|Failure compiling           |bogus "may overlap" memcpy
                   |constexpr/__builtin_memcpy  |warning with std::string
                   |on Cygwin with -std=c++20   |
             Target|                            |x86_64-pc-cygwin
           Keywords|                            |diagnostic

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
> Builds on gcc-11,12,13 with -std=c++17, but all three fail with c++20.

std::string changes slightly with C++20 and IIRC more inlining happens which is
why the warning happens only with -std=c++20.

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

* [Bug tree-optimization/105651] bogus "may overlap" memcpy warning with std::string
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
  2022-05-18 23:41 ` [Bug c++/105651] " mckelvey at maskull dot com
  2022-05-19  0:10 ` [Bug tree-optimization/105651] bogus "may overlap" memcpy warning with std::string pinskia at gcc dot gnu.org
@ 2022-05-19  6:19 ` rguenth at gcc dot gnu.org
  2022-05-24 17:48 ` mckelvey at maskull dot com
                   ` (23 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-19  6:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Both 9223372036854775807 and 9223372036854775810 are suspiciously large (don't
fit 64bits).

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

* [Bug tree-optimization/105651] bogus "may overlap" memcpy warning with std::string
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (2 preceding siblings ...)
  2022-05-19  6:19 ` rguenth at gcc dot gnu.org
@ 2022-05-24 17:48 ` mckelvey at maskull dot com
  2022-06-07 14:58 ` jens.maurer at gmx dot net
                   ` (22 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: mckelvey at maskull dot com @ 2022-05-24 17:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from James McKelvey <mckelvey at maskull dot com> ---
Still fails with gcc-12-20220521 and gcc-13-20220522, but not gcc-11-20220520.

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

* [Bug tree-optimization/105651] bogus "may overlap" memcpy warning with std::string
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (3 preceding siblings ...)
  2022-05-24 17:48 ` mckelvey at maskull dot com
@ 2022-06-07 14:58 ` jens.maurer at gmx dot net
  2022-06-21 17:33 ` pinskia at gcc dot gnu.org
                   ` (21 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: jens.maurer at gmx dot net @ 2022-06-07 14:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jens Maurer <jens.maurer at gmx dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jens.maurer at gmx dot net

--- Comment #5 from Jens Maurer <jens.maurer at gmx dot net> ---
Here's a more compact reproducer (gcc 12.1):

#include <string>

void f(const long long v)
{
   std::string line;
   line += " " + std::to_string(v);
}


$ g++ -Wall -O3 -std=c++20 -o test_warning.o -c test_warning.cxx
[...]
     inlined from 'void f(long long int)' at test_warning.cxx:9:15:
/opt/crosstool/x86_64-gcc-12.1.0-glibc-2.12.2/x86_64-unknown-linux-gnu/include/c++/12.1.0/bits/char_traits.h:431:56: 
warning: '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 [-Wrestrict]
   431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, 
__s2, __n));

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

* [Bug tree-optimization/105651] bogus "may overlap" memcpy warning with std::string
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (4 preceding siblings ...)
  2022-06-07 14:58 ` jens.maurer at gmx dot net
@ 2022-06-21 17:33 ` pinskia at gcc dot gnu.org
  2022-06-21 17:34 ` [Bug tree-optimization/105651] [12/13 Regression] " pinskia at gcc dot gnu.org
                   ` (20 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-06-21 17:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 106044 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (5 preceding siblings ...)
  2022-06-21 17:33 ` pinskia at gcc dot gnu.org
@ 2022-06-21 17:34 ` pinskia at gcc dot gnu.org
  2022-06-21 17:38 ` pinskia at gcc dot gnu.org
                   ` (19 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-06-21 17:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|bogus "may overlap" memcpy  |[12/13 Regression] bogus
                   |warning with std::string    |"may overlap" memcpy
                   |                            |warning with std::string
      Known to work|                            |11.1.0
   Target Milestone|---                         |12.2

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

* [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (6 preceding siblings ...)
  2022-06-21 17:34 ` [Bug tree-optimization/105651] [12/13 Regression] " pinskia at gcc dot gnu.org
@ 2022-06-21 17:38 ` pinskia at gcc dot gnu.org
  2022-07-08 11:56 ` [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3 marxin at gcc dot gnu.org
                   ` (18 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-06-21 17:38 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |needs-bisection,
                   |                            |needs-reduction
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-06-21
             Status|UNCONFIRMED                 |NEW

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Slightly more reduced testcase (still has system headers):
#include <string>

std::string f()
{
   return "_" + std::string(" ");
}

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

* [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (7 preceding siblings ...)
  2022-06-21 17:38 ` pinskia at gcc dot gnu.org
@ 2022-07-08 11:56 ` marxin at gcc dot gnu.org
  2022-07-19 23:10 ` pinskia at gcc dot gnu.org
                   ` (17 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-07-08 11:56 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection,            |
                   |needs-reduction             |
                 CC|                            |aldyh at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org

--- Comment #8 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r12-3347-g8af8abfbbace49e6 where new warning appeared:

    inlined from ‘std::string f()’ at pr105651.C:5:32:
/dev/shm/gcc-bisect-bin/usr/local/include/c++/12.0.0/bits/char_traits.h:355:56:
error: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’
specified bound between 9223372036854775810 and 18446744073709551615 exceeds
maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
  355 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2,
__n));
      |                                       
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~

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

* [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (8 preceding siblings ...)
  2022-07-08 11:56 ` [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3 marxin at gcc dot gnu.org
@ 2022-07-19 23:10 ` pinskia at gcc dot gnu.org
  2022-07-26  9:57 ` rguenth at gcc dot gnu.org
                   ` (16 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-19 23:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |me+gccbugzilla at s5 dot pm

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 106350 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (9 preceding siblings ...)
  2022-07-19 23:10 ` pinskia at gcc dot gnu.org
@ 2022-07-26  9:57 ` rguenth at gcc dot gnu.org
  2022-07-26 10:16 ` redi at gcc dot gnu.org
                   ` (15 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-07-26  9:57 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
             Status|NEW                         |ASSIGNED
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jwakely at redhat dot com

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
ISTR seeing this before.  We are quite confused by the standard library code
comparing the address of a string literal with the local buffer:

MEM[(char_type &)&D.42061 + 17] = 32;
if (&D.42061.D.33506._M_local_buf >= &MEM <const char[2]> [(void *)"_" + 1B])
  goto <bb 6>; [50.00%]
else
  goto <bb 7>; [50.00%]

if (&D.42061.D.33506._M_local_buf <= "_")
  goto <bb 8>; [50.00%]
else
  goto <bb 9>; [50.00%]

<bb 9> [local count: 21728216]:
_97 = &D.42061.D.33506._M_local_buf - "_";
if (_97 == 1)
  goto <bb 6>; [34.00%]
else
  goto <bb 10>; [66.00%]

and we are afraid of optimizing relational compares of distinct objects
(well, that's simply undefined and good QOI is to DWIM, simply leave the
broken code around if there's no good way to choose true or false).

This is all preceeded by an "overlap condition" working on integers
(so not undefined), so what might work is to aggressively simplify
relational compares of known distinct objects to __builtin_unreachable ()
(aka isolate the errorneous path).

<bb 2> [local count: 1073741824]:
MEM[(struct basic_string *)&D.42061] ={v} {CLOBBER};
MEM[(struct _Alloc_hider *)&D.42061] ={v} {CLOBBER};
MEM[(struct _Alloc_hider *)&D.42061]._M_p = &D.42061.D.33506._M_local_buf;
MEM[(char_type &)&D.42061 + 16] = 32;
D.42061._M_string_length = 1;
__x.25_69 = (long unsigned int) "_";
__y.26_70 = (long unsigned int) &D.42061.D.33506._M_local_buf;
if (__x.25_69 < __y.26_70)
  goto <bb 4>; [50.00%]
else
  goto <bb 3>; [50.00%]

<bb 3> [local count: 347651448]:
__x.25_72 = (long unsigned int) &MEM <char[16]> [(void *)&D.42061 + 17B];
if (__x.25_69 > __x.25_72)
  goto <bb 4>; [50.00%]
else
  goto <bb 5>; [50.00%]

Alternatively somehow re-combine the above overlap test and simplify
it statically.  We are getting into

Breakpoint 5, maybe_fold_and_comparisons (type=<boolean_type 0x7ffff68e2b28
bool>, code1=GE_EXPR, op1a=<ssa_name 0x7ffff4a88cf0 72>, op1b=<ssa_name
0x7ffff4a88c18 69>, code2=GE_EXPR, op2a=<ssa_name 0x7ffff4a88c18 69>,
op2b=<ssa_name 0x7ffff4a88c60 70>, outer_cond_bb=<basic_block 0x7ffff4d69548
(2)>)

we do have a patterns optimizing an overlap test (but not statically folding)
with

/* For pointers @0 and @2 and nonnegative constant offset @1, look for
   expressions like:

   A: (@0 + @1 < @2) | (@2 + @1 < @0)
   B: (@0 + @1 <= @2) | (@2 + @1 <= @0)
...

unfortunately simple matching in match.pd falls foul of the PR105142 fix
given _72 is computed in the inner block and thus
maybe_fold_comparisons_from_match_pd is not going to pick that up.
Without that fix

(for cmp1 (lt le le lt)
     cmp2 (lt le lt le)
(simplify
 (bit_and (cmp1:c (convert@4 @0) (convert @1)) (cmp2:c (convert@5 @2) (convert
@3)))
 (if (TREE_CODE (@0) == ADDR_EXPR
      && TREE_CODE (@1) == ADDR_EXPR
      && TREE_CODE (@2) == ADDR_EXPR
      && TREE_CODE (@3) == ADDR_EXPR
      && INTEGRAL_TYPE_P (TREE_TYPE (@4))
      && types_match (TREE_TYPE (@4), TREE_TYPE (@5)))
  (with { poly_int64 diff0, diff1; }
   (if (ptr_difference_const (@0, @3, &diff0)
        && ptr_difference_const (@1, @2, &diff1)
        && !ptr_derefs_may_alias_p (@0, @1))
    { constant_boolean_node (false, type); })))))

works to detect this for the case of invariant addresses which have the
offset included.  It would need to be extended for cases where the
increments are variable or the base address is not invariant (but common).

I'm going to improve the PR105142 fix.

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

* [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (10 preceding siblings ...)
  2022-07-26  9:57 ` rguenth at gcc dot gnu.org
@ 2022-07-26 10:16 ` redi at gcc dot gnu.org
  2022-07-26 10:20 ` jakub at gcc dot gnu.org
                   ` (14 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: redi at gcc dot gnu.org @ 2022-07-26 10:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|jwakely at redhat dot com          |redi at gcc dot gnu.org

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #10)
> ISTR seeing this before.

PR 105329 maybe?

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

* [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (11 preceding siblings ...)
  2022-07-26 10:16 ` redi at gcc dot gnu.org
@ 2022-07-26 10:20 ` jakub at gcc dot gnu.org
  2022-07-26 10:36 ` redi at gcc dot gnu.org
                   ` (13 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-07-26 10:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
My preference would be still to make the overlap case out-of-line as mentioned
in PR105329, but I don't have statistics on whether the overlap case is really
cold in real-world.  If yes, it would make non-overlap case smaller and the
overlap case tiny bit slower.

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

* [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (12 preceding siblings ...)
  2022-07-26 10:20 ` jakub at gcc dot gnu.org
@ 2022-07-26 10:36 ` redi at gcc dot gnu.org
  2022-07-26 10:46 ` rguenther at suse dot de
                   ` (12 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: redi at gcc dot gnu.org @ 2022-07-26 10:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think the vast majority of string mutations involve
inserting/appending/substituting an unrelated string, so non-overlapping. We
can make your change on trunk.

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

* [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (13 preceding siblings ...)
  2022-07-26 10:36 ` redi at gcc dot gnu.org
@ 2022-07-26 10:46 ` rguenther at suse dot de
  2022-07-26 12:19 ` rguenth at gcc dot gnu.org
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: rguenther at suse dot de @ 2022-07-26 10:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from rguenther at suse dot de <rguenther at suse dot de> ---
On Tue, 26 Jul 2022, jakub at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105651
> 
> --- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> My preference would be still to make the overlap case out-of-line as mentioned
> in PR105329, but I don't have statistics on whether the overlap case is really
> cold in real-world.  If yes, it would make non-overlap case smaller and the
> overlap case tiny bit slower.

I would say so.  It's of course still beneficial to optimize the
overlap test if possible.  I'm now testing a series of changes required.

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

* [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (14 preceding siblings ...)
  2022-07-26 10:46 ` rguenther at suse dot de
@ 2022-07-26 12:19 ` rguenth at gcc dot gnu.org
  2022-08-03  9:57 ` redi at gcc dot gnu.org
                   ` (10 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-07-26 12:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note on trunk we get things way less optimized and end up with

  <bb 32> [local count: 695302893]:
  __x.38_144 = (long unsigned int) " ";
  __y.39_145 = (long unsigned int) _137;
  if (__x.38_144 < __y.39_145)
    goto <bb 34>; [50.00%]
  else
    goto <bb 33>; [50.00%]

  <bb 33> [local count: 347651447]:
  _146 = _137 + _128;
  __x.38_147 = (long unsigned int) _146;
  if (__x.38_147 < __x.38_144)
    goto <bb 34>; [50.00%]
  else
    goto <bb 39>; [50.00%]

and ptr_derefs_may_alias_p doesn't work there because to relate _137 and " "
points-to info would need to track STRING_CSTs but it
doesn't do that (we simply drop knowledge here, see find_what_var_points_to
string_id handling).

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

* [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (15 preceding siblings ...)
  2022-07-26 12:19 ` rguenth at gcc dot gnu.org
@ 2022-08-03  9:57 ` redi at gcc dot gnu.org
  2022-10-19 10:11 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: redi at gcc dot gnu.org @ 2022-08-03  9:57 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hi at jdoubleu dot de

--- Comment #16 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 106512 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (16 preceding siblings ...)
  2022-08-03  9:57 ` redi at gcc dot gnu.org
@ 2022-10-19 10:11 ` rguenth at gcc dot gnu.org
  2022-10-19 10:48 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-19 10:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (17 preceding siblings ...)
  2022-10-19 10:11 ` rguenth at gcc dot gnu.org
@ 2022-10-19 10:48 ` redi at gcc dot gnu.org
  2022-10-19 11:08 ` [Bug tree-optimization/105651] [12 " rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-19 10:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #22 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #19)
> I've posted
> https://gcc.gnu.org/pipermail/gcc-patches/2022-July/598896.html
> patch for this, waiting for Jon's review.

N.B. that was committed as r13-2618-g723ef5a937dbab

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

* [Bug tree-optimization/105651] [12 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (18 preceding siblings ...)
  2022-10-19 10:48 ` redi at gcc dot gnu.org
@ 2022-10-19 11:08 ` rguenth at gcc dot gnu.org
  2022-12-12 10:24 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-19 11:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[12/13 Regression] bogus    |[12 Regression] bogus "may
                   |"may overlap" memcpy        |overlap" memcpy warning
                   |warning with std::string    |with std::string and
                   |and operator+ at -O3        |operator+ at -O3
      Known to work|                            |13.0
      Known to fail|13.0                        |

--- Comment #23 from Richard Biener <rguenth at gcc dot gnu.org> ---
The testcase from comment#5 is fixed on trunk, the preprocessed source of
course not as the workaround was in the library.  Still, fixed in GCC 13.

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

* [Bug tree-optimization/105651] [12 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (19 preceding siblings ...)
  2022-10-19 11:08 ` [Bug tree-optimization/105651] [12 " rguenth at gcc dot gnu.org
@ 2022-12-12 10:24 ` rguenth at gcc dot gnu.org
  2023-02-13 11:32 ` jg at jguk dot org
                   ` (5 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-12-12 10:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|rguenth at gcc dot gnu.org         |unassigned at gcc dot gnu.org
             Status|ASSIGNED                    |NEW

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

* [Bug tree-optimization/105651] [12 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (20 preceding siblings ...)
  2022-12-12 10:24 ` rguenth at gcc dot gnu.org
@ 2023-02-13 11:32 ` jg at jguk dot org
  2023-04-20  4:44 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: jg at jguk dot org @ 2023-02-13 11:32 UTC (permalink / raw)
  To: gcc-bugs

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

Jonny Grant <jg at jguk dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jg at jguk dot org

--- Comment #24 from Jonny Grant <jg at jguk dot org> ---
Hi, Glad it is fixed in trunk. I saw this fail in 12.2 - test case below.

#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";
}

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

* [Bug tree-optimization/105651] [12 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (21 preceding siblings ...)
  2023-02-13 11:32 ` jg at jguk dot org
@ 2023-04-20  4:44 ` pinskia at gcc dot gnu.org
  2023-04-20 12:00 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-20  4:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |f.heckenbach@fh-soft.de

--- Comment #25 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 109563 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/105651] [12 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (22 preceding siblings ...)
  2023-04-20  4:44 ` pinskia at gcc dot gnu.org
@ 2023-04-20 12:00 ` redi at gcc dot gnu.org
  2023-05-08 12:24 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  26 siblings, 0 replies; 28+ 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=105651

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvb at cyberscience dot com

--- Comment #26 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 105545 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/105651] [12 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (23 preceding siblings ...)
  2023-04-20 12:00 ` redi at gcc dot gnu.org
@ 2023-05-08 12:24 ` rguenth at gcc dot gnu.org
  2023-06-21 12:18 ` cvs-commit at gcc dot gnu.org
  2023-06-21 12:22 ` redi at gcc dot gnu.org
  26 siblings, 0 replies; 28+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-05-08 12:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|12.3                        |12.4

--- Comment #27 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 12.3 is being released, retargeting bugs to GCC 12.4.

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

* [Bug tree-optimization/105651] [12 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (24 preceding siblings ...)
  2023-05-08 12:24 ` rguenth at gcc dot gnu.org
@ 2023-06-21 12:18 ` cvs-commit at gcc dot gnu.org
  2023-06-21 12:22 ` redi at gcc dot gnu.org
  26 siblings, 0 replies; 28+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-06-21 12:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #28 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:636795a6dfc17ead7b22b9f76b0fc47bdb9d357d

commit r12-9716-g636795a6dfc17ead7b22b9f76b0fc47bdb9d357d
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Aug 18 23:53:16 2022 -0400

    libstdc++: avoid bogus -Wrestrict [PR105651]

            PR tree-optimization/105651

    libstdc++-v3/ChangeLog:

            * include/bits/basic_string.tcc (_M_replace): Add an assert
            to avoid -Wrestrict false positive.

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

* [Bug tree-optimization/105651] [12 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3
  2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
                   ` (25 preceding siblings ...)
  2023-06-21 12:18 ` cvs-commit at gcc dot gnu.org
@ 2023-06-21 12:22 ` redi at gcc dot gnu.org
  26 siblings, 0 replies; 28+ messages in thread
From: redi at gcc dot gnu.org @ 2023-06-21 12:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #29 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I've pushed the workaround from comment 17 to the gcc-12 branch.

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

end of thread, other threads:[~2023-06-21 12:22 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-18 23:38 [Bug c++/105651] New: Failure compiling constexpr/__builtin_memcpy on Cygwin with -std=c++20 mckelvey at maskull dot com
2022-05-18 23:41 ` [Bug c++/105651] " mckelvey at maskull dot com
2022-05-19  0:10 ` [Bug tree-optimization/105651] bogus "may overlap" memcpy warning with std::string pinskia at gcc dot gnu.org
2022-05-19  6:19 ` rguenth at gcc dot gnu.org
2022-05-24 17:48 ` mckelvey at maskull dot com
2022-06-07 14:58 ` jens.maurer at gmx dot net
2022-06-21 17:33 ` pinskia at gcc dot gnu.org
2022-06-21 17:34 ` [Bug tree-optimization/105651] [12/13 Regression] " pinskia at gcc dot gnu.org
2022-06-21 17:38 ` pinskia at gcc dot gnu.org
2022-07-08 11:56 ` [Bug tree-optimization/105651] [12/13 Regression] bogus "may overlap" memcpy warning with std::string and operator+ at -O3 marxin at gcc dot gnu.org
2022-07-19 23:10 ` pinskia at gcc dot gnu.org
2022-07-26  9:57 ` rguenth at gcc dot gnu.org
2022-07-26 10:16 ` redi at gcc dot gnu.org
2022-07-26 10:20 ` jakub at gcc dot gnu.org
2022-07-26 10:36 ` redi at gcc dot gnu.org
2022-07-26 10:46 ` rguenther at suse dot de
2022-07-26 12:19 ` rguenth at gcc dot gnu.org
2022-08-03  9:57 ` redi at gcc dot gnu.org
2022-10-19 10:11 ` rguenth at gcc dot gnu.org
2022-10-19 10:48 ` redi at gcc dot gnu.org
2022-10-19 11:08 ` [Bug tree-optimization/105651] [12 " rguenth at gcc dot gnu.org
2022-12-12 10:24 ` rguenth at gcc dot gnu.org
2023-02-13 11:32 ` jg at jguk dot org
2023-04-20  4:44 ` pinskia at gcc dot gnu.org
2023-04-20 12:00 ` redi at gcc dot gnu.org
2023-05-08 12:24 ` rguenth at gcc dot gnu.org
2023-06-21 12:18 ` cvs-commit at gcc dot gnu.org
2023-06-21 12:22 ` 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).