This test was relying on undefined behavior, with -Wundef I get

    gcc/testsuite/gcc.dg/pr102892-1.c: In function 'main':
    cc/testsuite/gcc.dg/pr102892-1.c:14:18: warning: 'a' is used uninitialized 
[-Wuninitialized]
       14 |   for (long a; a < 1; ++a)
          |                ~~^~~
    gcc/testsuite/gcc.dg/pr102892-1.c:14:13: note: 'a' was declared here
       14 |   for (long a; a < 1; ++a)
          |             ^

gcc/testsuite/ChangeLog:

        * gcc.dg/pr102892-1.c (main): Avoid undefined behavior.
---
The discussion on bug 102892
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102892> suggests this may
always have been a result of undefined behavior, but with these simple
changes the test passes for me.  No idea why we're hitting this in
RISC-V (and SPARC) and not elsewhere, and I also haven't gone back and
checked the original fix to see if it was always just UB causing the
issue.  Happy to look at this further, but one suggestion on bugzilla
was to just drop the test as invalid so I didn't want to chase something
that didn't matter.
---
 gcc/testsuite/gcc.dg/pr102892-1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/pr102892-1.c 
b/gcc/testsuite/gcc.dg/pr102892-1.c
index a9302b536df..b13f94d2a87 100644
--- a/gcc/testsuite/gcc.dg/pr102892-1.c
+++ b/gcc/testsuite/gcc.dg/pr102892-1.c
@@ -11,7 +11,7 @@ int
 main ()
 {
   long c = 0;
-  for (long a; a < 1; ++a)
+  for (long a = 0; a < 2; ++a)
     for (; c <= 1; c++) {
       bar();
       if (1 == b[c][0])
-- 
2.34.1

Reply via email to