From: Jeff Law <law@redhat.com>
To: Andreas Schwab <schwab@suse.de>, Martin Sebor <msebor@gmail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [committed] Make Wstringop-overflow-27 testnames unique [was Re: [PING 3][PATCH] track dynamic allocation in strlen (PR 91582)]
Date: Wed, 08 Jan 2020 18:48:00 -0000 [thread overview]
Message-ID: <57341c74051a1273aa54e5401277cb52b9410826.camel@redhat.com> (raw)
In-Reply-To: <mvma76yyxk5.fsf@suse.de>
[-- Attachment #1: Type: text/plain, Size: 1670 bytes --]
On Wed, 2020-01-08 at 12:52 +0100, Andreas Schwab wrote:
> On Dez 06 2019, Martin Sebor wrote:
>
> > diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-27.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-27.c
> > new file mode 100644
> > index 00000000000..249ce2b6ad5
> > --- /dev/null
> > +++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-27.c
> > +void test_strcpy_warn (const char *s)
> > +{
> > + {
> > + const char a[] = "123";
> > + /* Verify that using signed int for the strlen result works (i.e.,
> > + that the conversion from signed int to size_t doesn't prevent
> > + the detection. */
> > + int n = strlen (a);
> > + char *t = (char*)calloc (n, 1); // { dg-message "at offset 0 to an object with size 3 allocated by 'calloc' here" "calloc note" { xfail *-*-* } }
> > + // { dg-message "at offset 0 to an object with size at most 3 allocated by 'calloc' here" "calloc note" { target *-*-* } .-1 }
>
> Please make the test name unique.
>
> > + strcpy (t, a); // { dg-warning "writing 4 bytes into a region of size (between 0 and )?3 " }
> > +
> > + sink (t);
> > + }
> > +
> > + {
> > + const char a[] = "1234";
> > + size_t n = strlen (a);
> > + char *t = (char*)malloc (n); // { dg-message "at offset 0 to an object with size 4 allocated by 'malloc' here" "malloc note" { xfail *-*-* } }
> > + // { dg-message "at offset 0 to an object with size at most 4 allocated by 'malloc' here" "malloc note" { target *-*-* } .-1 }
>
> Likewise.
Fixed via the attached patch which I've committed to the trunk.
jeff
[-- Attachment #2: P --]
[-- Type: text/plain, Size: 2821 bytes --]
commit 48e76be17adbf93fe264fc118adbcf2ae6a14806
Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed Jan 8 18:46:33 2020 +0000
* gcc.dg/Wstringop-overflow-27.c: Make testnames unique.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@280016 138bc75d-0d04-0410-961f-82ee72b054a4
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 537091ffec6..622589e3db6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2020-01-08 Jeff Law <law@redhat.com>
+
+ * gcc.dg/Wstringop-overflow-27.c: Make testnames unique.
+
2020-01-08 Joel Brobecker <brobecker@adacore.com>
Olivier Hainque <hainque@adacore.com>
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-27.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-27.c
index 249ce2b6ad5..8e2cfe30725 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-27.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-27.c
@@ -260,8 +260,8 @@ void test_strcpy_warn (const char *s)
that the conversion from signed int to size_t doesn't prevent
the detection. */
int n = strlen (a);
- char *t = (char*)calloc (n, 1); // { dg-message "at offset 0 to an object with size 3 allocated by 'calloc' here" "calloc note" { xfail *-*-* } }
- // { dg-message "at offset 0 to an object with size at most 3 allocated by 'calloc' here" "calloc note" { target *-*-* } .-1 }
+ char *t = (char*)calloc (n, 1); // { dg-message "at offset 0 to an object with size 3 allocated by 'calloc' here" "calloc note 1" { xfail *-*-* } }
+ // { dg-message "at offset 0 to an object with size at most 3 allocated by 'calloc' here" "calloc note 2" { target *-*-* } .-1 }
strcpy (t, a); // { dg-warning "writing 4 bytes into a region of size (between 0 and )?3 " }
sink (t);
@@ -270,8 +270,8 @@ void test_strcpy_warn (const char *s)
{
const char a[] = "1234";
size_t n = strlen (a);
- char *t = (char*)malloc (n); // { dg-message "at offset 0 to an object with size 4 allocated by 'malloc' here" "malloc note" { xfail *-*-* } }
- // { dg-message "at offset 0 to an object with size at most 4 allocated by 'malloc' here" "malloc note" { target *-*-* } .-1 }
+ char *t = (char*)malloc (n); // { dg-message "at offset 0 to an object with size 4 allocated by 'malloc' here" "malloc note 1" { xfail *-*-* } }
+ // { dg-message "at offset 0 to an object with size at most 4 allocated by 'malloc' here" "malloc note 2" { target *-*-* } .-1 }
strcpy (t, a); // { dg-warning "writing 5 bytes into a region of size (between 0 and )?4 " }
sink (t);
}
next prev parent reply other threads:[~2020-01-08 18:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-12 4:53 [PATCH] track dynamic allocation in strlen (PR 91582) Martin Sebor
2019-11-18 19:04 ` Martin Sebor
2019-11-25 18:04 ` [PING 2][PATCH] " Martin Sebor
2019-12-07 0:19 ` [PING 3][PATCH] " Martin Sebor
2019-12-07 0:35 ` Jakub Jelinek
2019-12-11 23:23 ` Martin Sebor
2019-12-14 0:56 ` Martin Sebor
2019-12-15 11:25 ` Jeff Law
2019-12-17 15:31 ` Christophe Lyon
2020-01-08 11:53 ` Andreas Schwab
2020-01-08 18:42 ` Jeff Law
2020-01-08 18:48 ` Jeff Law [this message]
2019-11-30 17:03 ` [PATCH] " Christophe Lyon
2019-12-06 18:23 ` Martin Sebor
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=57341c74051a1273aa54e5401277cb52b9410826.camel@redhat.com \
--to=law@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=msebor@gmail.com \
--cc=schwab@suse.de \
/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).