[PATCH] spglobalcon01: LLVM optimization makes variable i always 1

Daniel Hellstrom daniel at gaisler.com
Fri Aug 24 13:32:48 UTC 2018


Declare i volatile to avoid compiler optimization putting i
into data section with initialization value 1.
---
 testsuites/sptests/spglobalcon01/init.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testsuites/sptests/spglobalcon01/init.cc b/testsuites/sptests/spglobalcon01/init.cc
index aee9d0a..f31ceca 100644
--- a/testsuites/sptests/spglobalcon01/init.cc
+++ b/testsuites/sptests/spglobalcon01/init.cc
@@ -27,10 +27,10 @@ class A {
       ++i;
     }
 
-    static int i;
+    static volatile int i;
 };
 
-int A::i;
+volatile int A::i;
 
 static A a;
 
-- 
2.7.4




More information about the devel mailing list