public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/103332] New: Spurious -Wstringop-overflow warnings in libstdc++ tests
Date: Fri, 19 Nov 2021 15:52:46 +0000	[thread overview]
Message-ID: <bug-103332-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 103332
           Summary: Spurious -Wstringop-overflow warnings in libstdc++
                    tests
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
            Blocks: 88443
  Target Milestone: ---

In the $objdir/$target/libstdc++-v3/testsuite dir, running:

make check
RUNTESTFLAGS="conformance.exp=21_strings/basic_string/operators/char/1.cc
--target_board=unix/-D_GLIBCXX_DEBUG"

Results in:

In file included from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/string:40,^M
                 from
/home/jwakely/src/gcc/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc:22:^M
In static member function 'static std::char_traits<char>::char_type*
std::char_traits<char>::copy(std::char_traits<char>::char_type*, const
std::char_traits<char>::char_type*, std::size_t)',^M
    inlined from 'std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&)
[with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>]' at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:675,^M
    inlined from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>
std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const
_CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>]' at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:3552,^M
    inlined from 'int test01()' at
/home/jwakely/src/gcc/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc:34:^M
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/char_traits.h:423:
warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)'
writing 17 bytes into a region of size 16 overflows the destination
[-Wstringop-overflow=]^M
/home/jwakely/src/gcc/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc:
In function 'int test01()':^M
/home/jwakely/src/gcc/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc:34:
note: at offset 16 into destination object '<anonymous>' of size 32^M
FAIL: 21_strings/basic_string/operators/char/1.cc (test for excess errors)
Excess errors:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/char_traits.h:423:
warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)'
writing 17 bytes into a region of size 16 overflows the destination
[-Wstringop-overflow=]


And:

make check
RUNTESTFLAGS="conformance.exp=21_strings/basic_string/capacity/char/1.cc
--target_board=unix/-std=gnu++20"

results in:

In file included from
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/string:40,^M
                 from
/home/jwakely/src/gcc/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc:22:^M
In static member function 'static constexpr std::char_traits<char>::char_type*
std::char_traits<char>::copy(std::char_traits<char>::char_type*, const
std::char_traits<char>::char_type*, std::size_t)',^M
    inlined from 'static constexpr void std::__cxx11::basic_string<_CharT,
_Traits, _Alloc>::_S_copy(_CharT*, const _CharT*,
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT =
char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:423,^M
    inlined from 'static constexpr void std::__cxx11::basic_string<_CharT,
_Traits, _Alloc>::_S_copy(_CharT*, const _CharT*,
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT =
char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:418,^M
    inlined from 'constexpr std::__cxx11::basic_string<_CharT, _Traits,
_Allocator>& std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::_M_append(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>;
_Alloc = std::allocator<char>]' at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:417,^M
    inlined from 'constexpr std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char;
_Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:1385,^M
    inlined from 'constexpr std::__cxx11::basic_string<_CharT, _Traits,
_Allocator> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits,
_Allocator>&, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)
[with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>]' at
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:3433,^M
    inlined from 'void test01()' at
/home/jwakely/src/gcc/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc:102:^M
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/char_traits.h:423:
warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)'
specified bound between 18446744073709551586 and 18446744073709551615 exceeds
maximum object size 9223372036854775807 [-Wstringop-overflow=]^M
FAIL: 21_strings/basic_string/capacity/char/1.cc (test for excess errors)
Excess errors:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/char_traits.h:423:
warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)'
specified bound between 18446744073709551586 and 18446744073709551615 exceeds
maximum object size 9223372036854775807 [-Wstringop-overflow=]



And:

make check 
RUNTESTFLAGS"=conformance.exp=experimental/filesystem/path/factory/u8path-char8_t.cc
--target_board=unix/-std=gnu++20"


results in:

[...]
FAIL: experimental/filesystem/path/factory/u8path-char8_t.cc (test for excess
errors)
Excess errors:
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/char_traits.h:423:
warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)'
reading between 16 and 9223372036854775806 bytes from a region of size 10
[-Wstringop-overread]
/home/jwakely/build/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/char_traits.h:423:
warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)'
reading between 16 and 9223372036854775806 bytes from a region of size 10
[-Wstringop-overread]



These are all bogus, as far as I can tell. e.g. for the last one, we read 9
bytes from a string literal that is 10 bytes long (including the null) and
memcpy it into a buffer that is 16 bytes in size. That doesn't overflow.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
[Bug 88443] [meta-bug] bogus/missing -Wstringop-overflow warnings

             reply	other threads:[~2021-11-19 15:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19 15:52 redi at gcc dot gnu.org [this message]
2021-11-19 16:03 ` [Bug tree-optimization/103332] " msebor at gcc dot gnu.org
2021-11-19 17:59 ` redi at gcc dot gnu.org
2021-11-19 18:16 ` cvs-commit at gcc dot gnu.org
2021-11-25 19:22 ` pinskia at gcc dot gnu.org
2021-12-08 23:30 ` [Bug tree-optimization/103332] [12 Regression] Spurious -Wstringop-overflow on string concatenation " msebor at gcc dot gnu.org
2021-12-09 23:24 ` cvs-commit at gcc dot gnu.org
2021-12-13 16:11 ` jason at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103332-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).