From: Brian McNamara (lorgon_at_[hidden])
Date: 2003-10-09 15:28:59
On Thu, Oct 09, 2003 at 01:00:35PM -0700, E. Gladyshev wrote:
> --- Brian McNamara <lorgon_at_[hidden]> wrote:
> > This is clever. Is it legal? I know it's legal for POD types. I can't
> > find text in the standard which makes it legal for non-POD types. But
> > at the same time, offhand I can't imagine an implementation where it
> > wouldn't work.
> Brian, where in my code do you see non-POD copying?
> All it does, it copies one char to another char
> (both are POD types).
> The char arrays where allocated as char arrays
> originally, there is not any casting going on.
> What are you concerns exactly?
My concern is that it is undefined behavior. As others have pointed
you (and me!) to, read
Whether or not this _ought_ to be undefined behavior is perhaps up for
debate. But the consensus among the language lawyers is that you are
simply not allowed to do this in C++ as it stands today, and I believe
them. You should too.
-- -Brian McNamara (lorgon_at_[hidden])
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk