[Libreoffice-commits] core.git: include/tools

Michael Stahl mstahl at redhat.com
Wed Nov 4 06:17:58 PST 2015


 include/tools/ref.hxx |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

New commits:
commit 6f1c202547d087d1115ab023f9b6ee4c230c6602
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Oct 30 15:22:26 2015 +0100

    tools: re-order members of SvRefBase to work around clang 3.5 bug
    
    http://fpaste.org/285206/ has minimized reproducer
    
    Change-Id: I898dfe0c3246a4ee2b093559530db5446d31e8bc
    Reviewed-on: https://gerrit.libreoffice.org/19692
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/tools/ref.hxx b/include/tools/ref.hxx
index e272777..45070a2 100644
--- a/include/tools/ref.hxx
+++ b/include/tools/ref.hxx
@@ -92,21 +92,19 @@ protected:
 /** Classes that want to be referenced-counted via SvRef<T>, should extend this base class */
 class TOOLS_DLLPUBLIC SvRefBase
 {
+    // work around a clang 3.5 optimization bug: if the bNoDelete is *first*
+    // it mis-compiles "if (--nRefCount == 0)" and never deletes any object
+    unsigned int nRefCount : 31;
     // the only reason this is not bool is because MSVC cannot handle mixed type bitfields
-#if defined(__AFL_HAVE_MANUAL_INIT)
-    bool bNoDelete;
-#else
     unsigned int bNoDelete : 1;
-#endif
-    unsigned int nRefCount : 31;
 
 protected:
     virtual         ~SvRefBase();
 
 public:
-                    SvRefBase() : bNoDelete(1), nRefCount(0) {}
+                    SvRefBase() : nRefCount(0), bNoDelete(1) {}
 
-                    SvRefBase( const SvRefBase & /* rObj */ )  : bNoDelete(1), nRefCount(0) {}
+                    SvRefBase(const SvRefBase &) : nRefCount(0), bNoDelete(1) {}
 
     SvRefBase &     operator = ( const SvRefBase & )
                     { return *this; }


More information about the Libreoffice-commits mailing list