6ca6e8
commit 26c7c6bac9da305b634a661aa491dae2756581ec
6ca6e8
Author: Joseph Myers <joseph@codesourcery.com>
6ca6e8
Date:   Tue Oct 5 14:25:40 2021 +0000
6ca6e8
6ca6e8
    Fix stdlib/tst-setcontext.c for GCC 12 -Warray-compare
6ca6e8
    
6ca6e8
    Building stdlib/tst-setcontext.c fails with GCC mainline:
6ca6e8
    
6ca6e8
    tst-setcontext.c: In function 'f2':
6ca6e8
    tst-setcontext.c:61:16: error: comparison between two arrays [-Werror=array-compare]
6ca6e8
       61 |   if (on_stack < st2 || on_stack >= st2 + sizeof (st2))
6ca6e8
          |                ^
6ca6e8
    tst-setcontext.c:61:16: note: use '&on_stack[0] < &st2[0]' to compare the addresses
6ca6e8
    
6ca6e8
    The comparison in this case is deliberate, so adjust it as suggested
6ca6e8
    in that note.
6ca6e8
    
6ca6e8
    Tested with build-many-glibcs.py (GCC mainline) for aarch64-linux-gnu.
6ca6e8
    
6ca6e8
    (cherry picked from commit a0f0c08e4fe18e78866539b0571f8e4b57dba7a3)
6ca6e8
6ca6e8
diff --git a/stdlib/tst-setcontext.c b/stdlib/tst-setcontext.c
6ca6e8
index 1b511708c1469444..1c2925bb760c9eb4 100644
6ca6e8
--- a/stdlib/tst-setcontext.c
6ca6e8
+++ b/stdlib/tst-setcontext.c
6ca6e8
@@ -58,7 +58,7 @@ f2 (void)
6ca6e8
   puts ("start f2");
6ca6e8
 
6ca6e8
   printf ("&on_stack=%p\n", on_stack);
6ca6e8
-  if (on_stack < st2 || on_stack >= st2 + sizeof (st2))
6ca6e8
+  if (&on_stack[0] < &st2[0] || &on_stack[0] >= st2 + sizeof (st2))
6ca6e8
     {
6ca6e8
       printf ("%s: memory stack is not where it belongs!", __FUNCTION__);
6ca6e8
       exit (1);