gold testsuite volatile fixes

Alan Modra amodra@gmail.com
Tue Dec 9 09:46:21 GMT 2025


Avoid these mainline gcc complaints (C23 WG14 n2743).
copy_test_relro.cc:42:5: error: ‘++’ expression of ‘volatile’-qualified type is deprecated [-Werror=volatile]
icf_test_pr21066.cc:50:55: error: ‘volatile’-qualified parameter is deprecated [-Werror=volatile]

	* testsuite/copy_test_relro.cc (segv): Avoid gcc warning.
	* testsuite/icf_test_pr21066.cc (capture_exception_of_type):
	Likewise.

diff --git a/gold/testsuite/copy_test_relro.cc b/gold/testsuite/copy_test_relro.cc
index c2a734d29bb..6cc1d350979 100644
--- a/gold/testsuite/copy_test_relro.cc
+++ b/gold/testsuite/copy_test_relro.cc
@@ -39,7 +39,7 @@ sigjmp_buf jmp;
 
 void segv(int)
 {
-  ++segfaults;
+  segfaults = segfaults + 1;
   siglongjmp(jmp, 1);
 }
 
diff --git a/gold/testsuite/icf_test_pr21066.cc b/gold/testsuite/icf_test_pr21066.cc
index 2b6c4da0ef0..33e52780f82 100644
--- a/gold/testsuite/icf_test_pr21066.cc
+++ b/gold/testsuite/icf_test_pr21066.cc
@@ -47,10 +47,11 @@ void raise_second_exception()
 }
 
 template<typename E>
-void capture_exception_of_type(volatile callback_fn_t f)
+void capture_exception_of_type(callback_fn_t f)
 {
+  volatile callback_fn_t vf = f;
   try {
-    f();
+    vf();
   } catch (E& e) {
     puts("caught expected exception");
   } catch (...) {

-- 
Alan Modra


More information about the Binutils mailing list