Re: [PATCH 1/2] alloca-opt-tests: add a ‘volatile’

2024-05-17 Thread Paul Eggert

On 2024-05-17 02:48, Bruno Haible wrote:

-flto was buggy for a long time. Is whole-program optimization working
fine for you? If so, which compiler version, binutils version, and
compiler options can you recommend?


No, I merely found that problem by program inspection. Like you, I've 
had problems with -flto.


The longer story is that my coreutils build was using GCC 14's new 
-Wmissing-variable-declarations behavior, which is a mistake for tests. 
While noticing the mistake I looked briefly at the complaints. This was 
an early test that -Wmissing-variable-declarations complained about and 
when I looked at the complaint I happened to notice the potential 
problem with whole-program optimization, something that has nothing to 
do with -Wmissing-variable-declarations.


In my weaker moments I sometimes think we should declare every test-case 
variable volatile, along the lines of the "volatile-by-default" approach 
for Java. See:


Liu L, Millstein T, Musuvathi M. Safe-by-default concurrency for modern 
programming languages. ACM TOPLAS. 2021;43(3):10. 
https://doi.org/10.1145/3462206




Re: [PATCH 1/2] alloca-opt-tests: add a ‘volatile’

2024-05-17 Thread Bruno Haible
Hi Paul,

> Now volatile, to foil whole-program optimization.

-flto was buggy for a long time. Is whole-program optimization working
fine for you? If so, which compiler version, binutils version, and
compiler options can you recommend?

Bruno






[PATCH 1/2] alloca-opt-tests: add a ‘volatile’

2024-05-16 Thread Paul Eggert
* tests/test-alloca-opt.c (func) [HAVE_ALLOCA]:
Now volatile, to foil whole-program optimization.
---
 ChangeLog   | 6 ++
 tests/test-alloca-opt.c | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 6436ddfb81..a8ed30c4ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-05-16  Paul Eggert  
+
+   alloca-opt-tests: add a ‘volatile’
+   * tests/test-alloca-opt.c (func) [HAVE_ALLOCA]:
+   Now volatile, to foil whole-program optimization.
+
 2024-05-16  Collin Funk  
 
byteswap tests: Strengthen tests.
diff --git a/tests/test-alloca-opt.c b/tests/test-alloca-opt.c
index 3f20779c9e..b22921758e 100644
--- a/tests/test-alloca-opt.c
+++ b/tests/test-alloca-opt.c
@@ -29,7 +29,7 @@ do_allocation (int n)
   (void) ptr;
 }
 
-void (*func) (int) = do_allocation;
+void (*volatile func) (int) = do_allocation;
 
 #endif
 
-- 
2.45.0