From 15a1c3b2ef5862a0be22f884c8071d659507795c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 4 Oct 2013 23:48:22 +0000 Subject: [PATCH] Work around g++ atomic builtins detection in configure when -Os is used. Assigning __sync_sub_and_fetch() result to an unused variable can result in it being optimized away and the function support is then not really tested for, see #4542. So do make sure this variable is kept by making it volatile. Closes #15555. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74934 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- build/aclocal/atomic_builtins.m4 | 2 +- configure | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/aclocal/atomic_builtins.m4 b/build/aclocal/atomic_builtins.m4 index 8366eb3ef4..eac5d3336a 100644 --- a/build/aclocal/atomic_builtins.m4 +++ b/build/aclocal/atomic_builtins.m4 @@ -16,7 +16,7 @@ AC_DEFUN([WX_ATOMIC_BUILTINS], __sync_fetch_and_add(&value, 2); __sync_sub_and_fetch(&value, 1); /* but wxAtomicDec does, so mimic that: */ - unsigned int r2 = __sync_sub_and_fetch(&value, 1); + volatile unsigned int r2 = __sync_sub_and_fetch(&value, 1); ], wx_cv_cc_gcc_atomic_builtins=yes, wx_cv_cc_gcc_atomic_builtins=no) diff --git a/configure b/configure index 7697a87f25..c922d7ee61 100755 --- a/configure +++ b/configure @@ -21867,7 +21867,7 @@ main () __sync_fetch_and_add(&value, 2); __sync_sub_and_fetch(&value, 1); /* but wxAtomicDec does, so mimic that: */ - unsigned int r2 = __sync_sub_and_fetch(&value, 1); + volatile unsigned int r2 = __sync_sub_and_fetch(&value, 1); ; return 0;