Boost logo

Boost Users :

Subject: Re: [Boost-users] [Review] Formal Review: Boost.Move
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2010-05-22 15:05:21


On 22/05/2010 17:49, Steven Watanabe wrote:
> There shouldn't be a cast through void*. Since
> boost::rv<T> inherits from T, it should just use
> a static_cast. The cast back to T is effectively
> a static_cast, and the two conversions need
> to match.

There's no conversion through void* but gcc still crashes with
static_cast. C++ aliasing rules allow accesing a type T by through a
base class, but we're accessing it through a non-existing derived type
(rv<T>) so, I think this breaks aliasing rules. Adding
__attribute__((__may_alias__)) to rv to tell the compiler that rv could
alias any type seems to fix the problem (although is overkill IMHO). See:

https://svn.boost.org/trac/boost/ticket/3950

Other compilers don't seem to have this problem and hopefully this
emulation is temporary until all compilers implement rvalue references.

Best,

Ion


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net