Subject: [Boost-bugs] [Boost C++ Libraries] #993: Variant should use least common multiple of alignments, rather than maximum
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2007-05-24 18:43:15
#993: Variant should use least common multiple of alignments, rather than maximum
--------------------------+-------------------------------------------------
Reporter: ebf | Owner: ebf
Type: Bugs | Status: new
Milestone: Boost 1.34.1 | Component: None
Version: | Severity: Problem
Keywords: |
--------------------------+-------------------------------------------------
'''Problem''':
Reported by Larry Evans on 19 May 2007:
{{{
The make_storage template at line 215 of:
http://boost.cvs.sourceforge.net/boost/boost/boost/variant/variant.hpp?revision=1.97&view=markup
uses max over the alignment_of's for the types in the variant
(See line2 233-235) to calculate the variant's alignment.
However, to handle the extended alignments described on page 3 of:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2165.pdf
the boost::math::static_lcm template should be used instead of max.
}}}
As described in the [http://www.open-
std.org/jtc1/sc22/wg21/docs/papers/2007/n2165.pdf cited document],
"alignments have an order from weaker to ... stricter alignments," and
"stricter alignments have larger alignment values."
But the problem is that "a larger alignment is not necessarily proper
alignment for a weaker alignment." Thus taking the maximum alignment does
not guarantee that the alignment is proper for types with weaker
alignments.
'''Proposed resolution''':
Use the `static_lcm` template as proposed by Larry. Choosing the least
common multiple of all the alignments results in a proper alignment for
all of the types because "an alignment requirement is satisfied by [any
alignment] that [is] a multiple of it."
--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/993>
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:49:55 UTC