Bug 106074 - Spurious Wstringop-overflow for int-to-string with SSE4
Summary: Spurious Wstringop-overflow for int-to-string with SSE4
Status: RESOLVED DUPLICATE of bug 106020
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 13.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wstringop-overflow
  Show dependency treegraph
 
Reported: 2022-06-24 08:59 UTC by Ed Catmur
Modified: 2023-05-18 03:58 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Catmur 2022-06-24 08:59:40 UTC
Code adapted from https://github.com/capnproto/capnproto/blob/be7a80b4add706ddaeb41689221146b86c3e0f5f/c%2B%2B/src/kj/string.c%2B%2B#L157-L203 :

auto f(short i) {
  struct R { char data[6]; } result;
  bool negative = i < 0;
  unsigned u = i;
  if (negative)
    u = -u;
  unsigned char reverse[5];
  unsigned char* p = reverse;
  if (u == 0)
    *p++ = 0;
  else
    for (; u > 0; u /= 10)
      *p++ = u % 10;
  char* p2 = result.data;
  if (negative)
    *p2++ = '-';
  while (p > reverse) {
#ifdef ASSUME
    if (p2 >= (&result.data)[1]) __builtin_unreachable();
#endif
    *p2++ = '0' + *--p;
  }
  if (p2 < (&result.data)[1])
    *p2 = '\0';
  return result;
}

When compiled with -O3 -msse4, from 12.1.0 through 13.0.0 20220619:

<source>: In function 'auto f(short int)':
<source>:21:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   21 |     *p2++ = '0' + *--p;
      |     ~~~~~~^~~~~~~~~~~~
<source>:2:19: note: at offset 6 into destination object 'f(short int)::R::data' of size 6
    2 |   struct R { char data[6]; } result;
      |                   ^~~~
<source>:2:30: note: at offset 7 into destination object 'result' of size 6
    2 |   struct R { char data[6]; } result;
      |                              ^~~~~~
<source>:2:19: note: at offset 6 into destination object 'f(short int)::R::data' of size 6
    2 |   struct R { char data[6]; } result;
      |                   ^~~~
<source>:2:19: note: at offset 6 into destination object 'f(short int)::R::data' of size 6
<source>:2:30: note: at offset 7 into destination object 'result' of size 6
    2 |   struct R { char data[6]; } result;
      |                              ^~~~~~
<source>:2:19: note: at offset 6 into destination object 'f(short int)::R::data' of size 6
    2 |   struct R { char data[6]; } result;
      |                   ^~~~
<source>:2:19: note: at offset 6 into destination object 'f(short int)::R::data' of size 6
<source>:2:30: note: at offset 7 into destination object 'result' of size 6
    2 |   struct R { char data[6]; } result;
      |                              ^~~~~~
<source>:2:19: note: at offset 6 into destination object 'f(short int)::R::data' of size 6
    2 |   struct R { char data[6]; } result;
      |                   ^~~~
<source>:2:19: note: at offset 6 into destination object 'f(short int)::R::data' of size 6
<source>:2:30: note: at offset 7 into destination object 'result' of size 6
    2 |   struct R { char data[6]; } result;
      |                              ^~~~~~
<source>:2:19: note: at offset 6 into destination object 'f(short int)::R::data' of size 6
    2 |   struct R { char data[6]; } result;
      |                   ^~~~

Adding the assumption at line 19 (-DASSUME) works around this.
Comment 1 Ed Catmur 2022-07-07 12:16:53 UTC
Another example, using Date 3.0.1:

#include <date/date.h>
void f(std::istream s) {
    std::chrono::system_clock::time_point tp;
    date::from_stream(s, "%Y", tp);
}

https://godbolt.org/z/fscqTd947

In file included from /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_pair.h:61,
                 from /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:64,
                 from /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/algorithm:60,
                 from /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:44,
                 from <source>:1:
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {char&, const char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&, char&, const char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6474:9:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&, char&, const char&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 19 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [3, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 19 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {char&, const char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&, char&, const char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6474:9:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&, char&, const char&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 20 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [4, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 20 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {char&, const char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&, char&, const char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6474:9:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&, char&, const char&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 21 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [5, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 21 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {char&, const char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&, char&, const char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6474:9:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&, char&, const char&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 22 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [6, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 22 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6501:1,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6474:9:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 19 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [3, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 19 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6501:1,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6474:9:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 20 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [4, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 20 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6501:1,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6474:9:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 21 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [5, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 21 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6501:1,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6474:9:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, CharT, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {int&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 22 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [6, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 22 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {const char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {const char&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 19 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [3, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 19 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {const char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {const char&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 20 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [4, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 20 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {const char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {const char&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 21 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [5, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 21 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {const char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {const char&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 22 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [6, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 22 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {char&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 19 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [3, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 19 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {char&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 20 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [4, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 20 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {char&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 21 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [5, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 21 into destination object 'buf' of size 11
In function 'constexpr std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = char]',
    inlined from 'constexpr void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = char*; _ForwardIterator2 = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algobase.h:182:11,
    inlined from 'constexpr void std::__reverse(_RandomAccessIterator, _RandomAccessIterator, random_access_iterator_tag) [with _RandomAccessIterator = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1107:18,
    inlined from 'constexpr void std::reverse(_BIter, _BIter) [with _BIter = char*]' at /opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/stl_algo.h:1134:21,
    inlined from 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {char&}]' at /opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6513:21:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/move.h:205:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  205 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h: In function 'void date::detail::read(std::basic_istream<_CharT, _Traits>&, int, Args&& ...) [with CharT = char; Traits = std::char_traits<char>; Args = {char&}]':
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 22 into destination object 'buf' of size 11
 6506 |         CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
      |               ^~~
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset [6, 11] into destination object 'buf' of size 11
/opt/compiler-explorer/libs/date/v3.0.1/include/date/date.h:6506:15: note: at offset 22 into destination object 'buf' of size 11
Comment 2 Andrew Pinski 2023-05-18 03:58:35 UTC
I just reduced a very similar testcase for PR 106020. Marking this as a dup.

The Date is exactly what I reduced really.

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