Boost logo

Boost :

Subject: Re: [boost] aligned_storage in unions
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-09-22 13:35:39


On 09/22/10 05:20, Mathias Gaunard wrote:
[snip]
> That approach is fundamentally broken as this is not allowed by the
> strict aliasing rules of C++.
>
> Every other utility that uses it, such as variant and optional, are
> broken too; but they've got no other choice for their implementation,
> unfortunately, at least until C++0x.

How would C++0x avoid the problem? A google of "strict aliasing rule"
turned up:

http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html

which says:

  Strict aliasing is an assumption, made by the C (or C++) compiler,
  that dereferencing pointers to objects of different types will
  never refer to the same memory location (i.e. alias each other.)

Could you point to the variant code violating this rule?

TIA.

-Larry


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