This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] Fix variant::operator= on references


On 22/09/16 00:43 -0700, Tim Shen wrote:
Hi, this patch fixes the following compilation failure:

#include <variant>

int main()
{
  float f1 = 1.0f, f2 = 2.0f;

  std::variant<float&> v1(f1);

  v1 = f2; // #1
}

The bug is caused by a misuse of __storage. I also examined other
__storage usage, they all seem appropriate.

@@ -1147,8 +1147,7 @@ namespace __variant
       {
         constexpr auto __index = __accepted_index<_Tp&&>;
         if (index() == __index)
-           *static_cast<__storage<__to_type<__index>>*>(this->_M_storage())
-             = forward<_Tp>(__rhs);
+           std::get<__index>(*this) = forward<_Tp>(__rhs);

Please qualify std::forward here.

OK for trunk with that change, thanks for the quick fix.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]