]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix stdlib/tst-setcontext.c for GCC 12 -Warray-compare
authorJoseph Myers <joseph@codesourcery.com>
Tue, 5 Oct 2021 14:25:40 +0000 (14:25 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Tue, 5 Oct 2021 14:25:40 +0000 (14:25 +0000)
Building stdlib/tst-setcontext.c fails with GCC mainline:

tst-setcontext.c: In function 'f2':
tst-setcontext.c:61:16: error: comparison between two arrays [-Werror=array-compare]
   61 |   if (on_stack < st2 || on_stack >= st2 + sizeof (st2))
      |                ^
tst-setcontext.c:61:16: note: use '&on_stack[0] < &st2[0]' to compare the addresses

The comparison in this case is deliberate, so adjust it as suggested
in that note.

Tested with build-many-glibcs.py (GCC mainline) for aarch64-linux-gnu.

stdlib/tst-setcontext.c

index 1b511708c1469444744a6498b2ff48e0bd15b77c..1c2925bb760c9eb4a5e735e050516c7253cac7b6 100644 (file)
@@ -58,7 +58,7 @@ f2 (void)
   puts ("start f2");
 
   printf ("&on_stack=%p\n", on_stack);
-  if (on_stack < st2 || on_stack >= st2 + sizeof (st2))
+  if (&on_stack[0] < &st2[0] || &on_stack[0] >= st2 + sizeof (st2))
     {
       printf ("%s: memory stack is not where it belongs!", __FUNCTION__);
       exit (1);