Boost logo

Boost Users :

Subject: Re: [Boost-users] Seeding boost::mt19937 with bytes from CryptoGenRandom
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-02-11 13:39:36


AMDG

Ovanes Markarian wrote:
> I know at least 2 books which describe this possibility and there is nothing
> stated about undefined behavior.

Unfortunately this is a very common mistake even among those
who ought to know better.

> I just double checked the ISO 2003 C++
> Standards and did not find anything which disallows the presented approach.
> Can you point me to the paragraph in the Standard?
>

The usual aliasing rules apply with only one exception (listed in 9.5):

[Note: one special guarantee is made in order to
simplify the use of unions: If a POD-union contains several POD-structs
that share a common initial
sequence (9.2), and if an object of this POD-union type contains one of
the POD-structs, it is permitted to
inspect the common initial sequence of any of POD-struct members; see 9.2. ]

In Christ,
Steven Watanabe


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