Hi,
Find attached a patch that fixes compilation on gcc 4.6.2 (OpenSUSE
12.1 + Tumbleweed) with the following autogen.lastrun:
--enable-werror
--enable-kde4
--with-num-cpus=2
--with-max-jobs=2
See commit message for more details.
What I don't understand is why am I the only one hitting this. I think
GCC only does the analysis to warn about uninitialized variables when
compiled with optimization, but still: am I the only one with this GCC
version that compiled with optimization and --enable-werror?
From 78d778a79cfe2292d03ac30bee825147cc56ead9 Mon Sep 17 00:00:00 2001
From: Catalin Iacob <iacobcatalin@gmail.com>
Date: Wed, 14 Mar 2012 23:35:49 +0100
Subject: [PATCH] Initialize m_hFile in FileMapping constructor.
GCC gives the following warning which breaks compilation when using --enable-werror:
lockbyte.cxx: In function 'storeError 
store::FileLockBytes_createInstance(rtl::Reference<store::ILockBytes>&, rtl_uString*, 
storeAccessMode)':
lockbyte.css:512:37: error: 'prephitmp.221' may be used uninitialized in this function 
[-Werror=uninitialized]
lockbyte.cxx:906:1: note: 'prephitmp.221' was declared here
It's not clear from GCC's message, but what it warns about is
FileMapping::m_hFile. This is because of the following sequence:
* xMapping.release() makes xMapping.m_value be a default constructed
  FileMapping
* the xMapping local variable in store::FileLockBytes_createInstance
  gets destructed
* ~ResourceHolder() calls ResourceHolder::reset
* ResourceHolder::reset() calls FileMapping::UnmapFile::operator()
  passing m_value as rMapping
* FileMapping::UnmapFile::operator() uses rMapping.m_hFile but
  rMapping is a default constructed FileMapping and therefore has
  m_hFile uninitialized
---
 store/source/lockbyte.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/store/source/lockbyte.cxx b/store/source/lockbyte.cxx
index e28bffe..1a8bf81 100644
--- a/store/source/lockbyte.cxx
+++ b/store/source/lockbyte.cxx
@@ -478,7 +478,7 @@ struct FileMapping
     sal_uInt32  m_nSize;
     oslFileHandle m_hFile;
 
-    FileMapping() : m_pAddr(0), m_nSize(0) {}
+    FileMapping() : m_pAddr(0), m_nSize(0), m_hFile() {}
 
     bool operator != (FileMapping const & rhs) const
     {
-- 
1.7.9.2
Context
- [PATCH] Initialize m_hFile in FileMapping constructor. · Catalin Iacob
 
   
 
  Privacy Policy |
  
Impressum (Legal Info) |
  
Copyright information: Unless otherwise specified, all text and images
  on this website are licensed under the
  
Creative Commons Attribution-Share Alike 3.0 License.
  This does not include the source code of LibreOffice, which is
  licensed under the Mozilla Public License (
MPLv2).
  "LibreOffice" and "The Document Foundation" are
  registered trademarks of their corresponding registered owners or are
  in actual use as trademarks in one or more countries. Their respective
  logos and icons are also subject to international copyright laws. Use
  thereof is explained in our 
trademark policy.