Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#11697 closed Bugs (fixed)

Boost.Container: Wrong initialization order in tuple copy-constructor

Reported by: Manuel Freiberger <manuel.freiberger@…> Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: container
Version: Boost 1.59.0 Severity: Problem
Keywords: Cc:

Description

Hello,

In the file

boost/container/detail/variadic_templates_tools.hpp

in line 57 there is a bug because the inherited class comes in the initialization list after the member. The code should read

Construct tuple from another tuple. template<typename... VValues> tuple(const tuple<VValues...>& other)

: m_head(other.head()), inherited(other.tail()) : inherited(other.tail()), m_head(other.head())

{}

Best regards, Manuel

Change History (4)

comment:1 by Manuel Freiberger <manuel.freiberger@…>, 7 years ago

Component: Nonecontainer
Owner: set to Ion Gaztañaga

comment:2 by Manuel Freiberger <manuel.freiberger@…>, 7 years ago

Second try (now with the code embedded in a code block):

   // Construct tuple from another tuple.
   template<typename... VValues>
   tuple(const tuple<VValues...>& other)
      // : m_head(other.head()), inherited(other.tail())
      : inherited(other.tail()), m_head(other.head())
   {}

comment:3 by Ion Gaztañaga, 7 years ago

Resolution: fixed
Status: newclosed

Thanks for the report. Inherited will always be constructed first, as the initialization order is fixed by the language despite the initialization list. In any case, it's misleading and it should be corrected. Fixed in commit:

https://github.com/boostorg/container/commit/79274e4aae91c563be1e49046bdf98b589d35294

comment:4 by Manuel Freiberger <manuel.freiberger@…>, 7 years ago

The code was not wrong, I should have been clearer in my wording. The "problem" is that our compiler (ARMCC) reports a warning in this case. Thanks for silencing it! :-)

Note: See TracTickets for help on using tickets.