Subject: [Boost-bugs] [Boost C++ Libraries] #12577: Null reference in pair.hpp triggers runtime warning with -fsanitize=undefined
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-11-02 13:34:09
#12577: Null reference in pair.hpp triggers runtime warning with
-fsanitize=undefined
------------------------------+------------------------
Reporter: antoinep92@⦠| Owner: igaztanaga
Type: Bugs | Status: new
Milestone: To Be Determined | Component: container
Version: Boost 1.62.0 | Severity: Problem
Keywords: |
------------------------------+------------------------
I tagged 1.62 which is where I discovered the issue, but master at github
seems affected as well.
Consider this minimal file:
{{{
#include <boost/container/flat_map.hpp>
int main() { return 0; }
}}}
When built with gcc 6.2 and undefined sanitizers, `g++
-fsanitize=address`, the resulting executable triggers the following
warning at runtime during static initialization:
{{{
/usr/include/boost/container/detail/pair.hpp:85:30: runtime error:
reference binding to null pointer of type 'const struct
piecewise_construct_t'
}}}
This doesn't happen with clang 3.9, so it *might* be a bug in gcc, but
when looking at the boost code, I'd say gcc is right. Indeed, in
`container/detail/pair.hpp` (line 85 in 1.62 and master), the static
global variable `boost::container::piecewise_construct` is defined, of
type `const std::piecewise_construct_t &`, and value
`*boost::container::std_piecewise_construct_holder<0>::dummy`, defined in
the same file, but (as far as I can tell), uninitialized.
I'm not well positioned to assess the bug severity: either the
null/uninitialized reference is never used, and the gcc warning can be
ignored (although it's annoying); or there are situations the reference's
address is dereferenced, and this can lead to crashes.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/12577> 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