Sam James noticed a 'test-memset_explicit' failure with unreleased gcc,
reported it at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111904
and Alexandre Oliva found a fix. Thanks to both of you!

I'm adding your fix to gnulib.


2023-10-22  Bruno Haible  <br...@clisp.org>

        memset_explicit, explicit_bzero tests: Fix test failures with new gcc.
        Reported by Sam James <s...@gentoo.org> in
        <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111904>.
        Fix by Alexandre Oliva <aol...@gcc.gnu.org>.
        * tests/test-memset_explicit.c (do_secret_stuff): Declare with
        attributes 'noclone' and 'noipa'.
        * tests/test-explicit_bzero.c (do_secret_stuff): Likewise.

diff --git a/tests/test-explicit_bzero.c b/tests/test-explicit_bzero.c
index 9754750e13..f29f0ea0da 100644
--- a/tests/test-explicit_bzero.c
+++ b/tests/test-explicit_bzero.c
@@ -133,6 +133,12 @@ test_heap (void)
    does not eliminate a call to explicit_bzero, even if data flow analysis
    reveals that the stack area is dead at the end of the function.  */
 static bool _GL_ATTRIBUTE_NOINLINE
+#if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4
+__attribute__ ((__noclone__))
+#endif
+#if __GNUC__ >= 8
+__attribute__ ((__noipa__))
+#endif
 do_secret_stuff (int volatile pass, char *volatile *volatile last_stackbuf)
 {
   char stackbuf[SECRET_SIZE];
diff --git a/tests/test-memset_explicit.c b/tests/test-memset_explicit.c
index b36a7cfe76..cdc7fc30b2 100644
--- a/tests/test-memset_explicit.c
+++ b/tests/test-memset_explicit.c
@@ -143,6 +143,12 @@ test_heap (void)
    does not eliminate a call to memset_explicit, even if data flow analysis
    reveals that the stack area is dead at the end of the function.  */
 static bool _GL_ATTRIBUTE_NOINLINE
+#if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4
+__attribute__ ((__noclone__))
+#endif
+#if __GNUC__ >= 8
+__attribute__ ((__noipa__))
+#endif
 do_secret_stuff (int volatile pass, char *volatile *volatile last_stackbuf)
 {
   char stackbuf[SECRET_SIZE];




Reply via email to