public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r12-1641] libstdc++: Suppress -Wstringop-overread warning in test
Date: Fri, 18 Jun 2021 10:15:43 +0000 (GMT)	[thread overview]
Message-ID: <20210618101543.7AE67386197D@sourceware.org> (raw)

https://gcc.gnu.org/g:92edc4a7684cdad5d30e197b976c35b2257f7bed

commit r12-1641-g92edc4a7684cdad5d30e197b976c35b2257f7bed
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Jun 18 11:08:19 2021 +0100

    libstdc++: Suppress -Wstringop-overread warning in test
    
    When compiled with -m32 -O2 -D_GLIBCXX_USE_CXX11_ABI=0 we get a warning
    for 21_strings/basic_string/cons/char/1.cc:
    
    bits/char_traits.h:409:56: warning: ‘void* __builtin_memcpy(void*, const void*, unsigned int)’ reading 1073741821 bytes from a region of size 19 [-Wstringop-overread]
    
    The warning is legitimate, even if that line cannot be reached because
    we throw std::length_error before getting there. Since the invalid
    length is deliberate (and mentioned in a comment) just suppress the
    warning, so that the test can verify we get the exception.
    
    Also remove an unused typedef that produces another warning.
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/21_strings/basic_string/cons/char/1.cc: Use
            diagnostic pragma to suppress -Wstringop-overread error.
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

Diff:
---
 libstdc++-v3/testsuite/21_strings/basic_string/cons/char/1.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/1.cc
index 5549094553e..099921f0941 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/1.cc
@@ -36,7 +36,6 @@ using namespace std;
 void test01(void)
 {
   typedef string::size_type csize_type;
-  typedef string::iterator citerator;
   csize_type npos = string::npos;
   csize_type csz01;
 
@@ -68,6 +67,8 @@ void test01(void)
 
   // basic_string(const char* s, size_type n, alloc)
   csz01 = str01.max_size();
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overread"
   // NB: As strlen(str_lit01) != csz01, this test is undefined. It
   // should not crash, but what gets constructed is a bit arbitrary.
   try {
@@ -94,6 +95,7 @@ void test01(void)
   catch(...) {
     VERIFY( false );
   }
+#pragma GCC diagnostic pop
 
   // Build a maxsize - 1 lengthed string consisting of all A's
   try {


                 reply	other threads:[~2021-06-18 10:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210618101543.7AE67386197D@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@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).