[Boost-bugs] [Boost C++ Libraries] #12513: Boost optional (1.60/1.61/1.62) generates "may be used uninitialized" warnings with gcc 6

Subject: [Boost-bugs] [Boost C++ Libraries] #12513: Boost optional (1.60/1.61/1.62) generates "may be used uninitialized" warnings with gcc 6
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-10-10 21:57:44


#12513: Boost optional (1.60/1.61/1.62) generates "may be used uninitialized"
warnings with gcc 6
------------------------------------------------+-----------------------
 Reporter: romain.geissler@… | Owner: fcacciola
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: optional
  Version: Boost 1.60.0 | Severity: Problem
 Keywords: optional gcc warning uninitialized |
------------------------------------------------+-----------------------
 Hi,

 I have met a small case where boost::optional wrongly generates gcc
 warnings about maybe uninitialized values. I could reduce my case and
 provide the attached reproducer.

 Note that this warning only happens when optimization are used (-O1 or -O2
 while strangely no warning is emitted with -O3).

 It's built with (from a Fedora rawhide Docker container just cloned):
 [root_at_a064b4c04fc9 tmp]# g++ -std=gnu++14 -O2 -Wall -c -o test.o
 test.cpp
 test.cpp: In function 'void someFunction(const void*)':
 test.cpp:22:16: warning: '*((void*)& aOptional +4)' may be used
 uninitialized in this function [-Wmaybe-uninitialized]
      Optional_t aOptional;
                 ^~~~~~~~~
 [root_at_a064b4c04fc9 tmp]# g++ --version
 g++ (GCC) 6.2.1 20160916 (Red Hat 6.2.1-2)
 Copyright (C) 2016 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions. There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.

 Other bug reports in Boost are always mentioning
 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47679 as the root cause, but
 this is not true anymore since this gcc bug was closed last year and all
 commits made at the time have been released in gcc 6. Please note that I
 could reproduce as well with the latest trunk from gcc 7.

 This was reproduced with both Boost 1.60 and 1.61, but should happen as
 well in Boost 1.62 given that boost::optional did almost not change.

 Also note that using std::experiment::optional from gcc's libstdc++
 implementation works just fine.

 I am not sure whether this is actually a Boost bug or a gcc one. If it's a
 gcc one then it's seems to be different from
 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47679.

 Can you please have a look.

 Thanks,
 Romain

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12513>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC