Boost logo

Boost Users :

Subject: Re: [Boost-users] [Spirit] dereferencing type-punned pointer will break strict-aliasing rules
From: David Abrahams (dave_at_[hidden])
Date: 2010-08-11 20:25:28

At Wed, 11 Aug 2010 16:07:31 -0700,
Emil Dotchevski wrote:
> > Really, the reinterpret_cast is portably correct?  Pretty much the
> > only thing you can do portably with reinterpret_cast is round-trip
> > cast a pointer type to another pointer type and then cast it back
> > before you use it again.
> That's what this code does.
> Honestly, I'm probably giving the compiler too much credit, since I
> assumed that it sees that the object it's taking the address of is a
> single char, not an array of chars. In reality it's probably not that
> clever and the warning is plain wrong because in general strict
> aliasing rules don't apply to char pointers, do they?

I dunno, sorry.

Dave Abrahams
BoostPro Computing

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at