Boost logo

Boost :

Subject: Re: [boost] [optional] Changes in Boost.Optional
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2014-09-02 10:17:03


2014-09-02 16:11 GMT+02:00 Dean Michael Berris <mikhailberis_at_[hidden]>:

> On Wed Sep 03 2014 at 12:00:56 AM Andrzej Krzemienski <akrzemi1_at_[hidden]>
> wrote:
>
> >
> > And the above incorrect behaviour is the consequence of a more simple bug
> > in VC++. It allows two user defined conversions in copy initialization:
> >
> > struct A
> > {
> > A(int &&) {}
> >
> > };
> >
> > struct B
> > {
> > operator int() { return 0; }
> > };
> >
> > int main()
> > {
> > A t = B();
> > }
> >
> > This works in VC++, although the code is incorrect.
> >
> >
> So it does sound like this is one of those r-value reference implementation
> bugs in MSVC that I've heard before but couldn't cite. Could it just be
> that Boost.Optional shouldn't turn on rvalue reference support with MSVC
> 2010? Will defining just the copy constructor "fix" it? More importantly is
> there something users of Boost 1.56.0 can do to side-step this particular
> issue in Boost.Optional?
>

No, it has nothing to do with rvalue refs -- only with illegal double
conversion.

struct A
{
  A(int) {}
};

struct B
{
  operator int() { return 0; }
};

int main()
{
  A t = B();
}

This is also an illegal C++ but VC++ allows it. See my other reply for a
workaround.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk