|
Boost : |
Subject: [boost] [parameter] aux_/void.hpp: potential undefined behavior
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2011-11-03 09:57:28
Hello,
Here's boost/aux_/void.hpp contents, without include quards and license
note, where I marked a line with a comment to refer to it below.
[code]
namespace boost { namespace parameter {
// A placemarker for "no argument passed."
// MAINTAINER NOTE: Do not make this into a metafunction
struct void_ {};
namespace aux
{
inline void_& void_reference()
{
static void_ instance; // (1)
return instance;
}
} // namespace aux
}} // namespace boost::parameter
[/code]
My question is: is it allowed to use an instance of an uninitialized empty
struct?
The struct void_ is empty. On line (1) a static uninitialized instance of
struct void_ is defined, and it is then returned. Does the standard allow
this? I can't imagine any real problems with this, but I'm curious if this
has defined behavior according to the standard.
A natural and simple solution to my concern is of course to change the line
(1) to:
static void_ instance = {};
I'd be happy to create a ticket with a patch, if my concern is valid.
Regards,
Kris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk