public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-8599] Backported from trunk:
@ 2021-06-17 20:07 Martin Sebor
0 siblings, 0 replies; only message in thread
From: Martin Sebor @ 2021-06-17 20:07 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a52b2f4cae38abecda2a7ad72a47c4e38236870a
commit r11-8599-ga52b2f4cae38abecda2a7ad72a47c4e38236870a
Author: Martin Sebor <msebor@redhat.com>
Date: Thu Jun 17 10:20:09 2021 -0600
Backported from trunk:
PR middle-end/100250 - ICE related to -Wmaybe-uninitialized
gcc/ChangeLog:
PR middle-end/100250
* attribs.c (attr_access::array_as_string): Avoid dereferencing
a pointer when it's null.
gcc/testsuite/ChangeLog:
PR middle-end/100250
* gcc.dg/uninit-pr100250.c: New test.
Diff:
---
gcc/attribs.c | 3 ++-
gcc/testsuite/gcc.dg/uninit-pr100250.c | 29 +++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/gcc/attribs.c b/gcc/attribs.c
index 3ffa1b6bc81..ebc0783c439 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -2388,7 +2388,8 @@ attr_access::array_as_string (tree type) const
const char *p = end;
for ( ; p != str && *p-- != ']'; );
if (*p == '$')
- index_type = build_index_type (TREE_VALUE (size));
+ /* SIZE may have been cleared. Use it with care. */
+ index_type = build_index_type (size ? TREE_VALUE (size) : size);
}
else if (minsize)
index_type = build_index_type (size_int (minsize - 1));
diff --git a/gcc/testsuite/gcc.dg/uninit-pr100250.c b/gcc/testsuite/gcc.dg/uninit-pr100250.c
new file mode 100644
index 00000000000..8e7a787ddac
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr100250.c
@@ -0,0 +1,29 @@
+/* PR middle-end/100250 - ICE related to -Wmaybe-uninitialized
+ { dg-do compile }
+ { dg-options "-O2 -Wall" } */
+
+extern void f (int D, const int[D], const int[D]);
+
+void g (int D, const int a[D], const int b[D], const int c[D], const int d[D])
+{
+ int c2[D];
+
+ for (int i = 0; i < D; i++) {
+
+ if (a[i] >= D) __builtin_abort ();
+ if (b[i] != d[a[i]]) __builtin_abort ();
+
+ c2[a[i]] = c[i];
+ }
+
+ f (D, d, c2);
+}
+
+void h (int D, const int d[D])
+{
+ int a[D];
+ int b[D];
+ int c[D];
+
+ g (D, a, b, c, d); // { dg-warning "-Wmaybe-uninitialized" }
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-17 20:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 20:07 [gcc r11-8599] Backported from trunk: Martin Sebor
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).