When is array-to-array cast legal, and what does actually happen?

2010-02-22 Thread Ali Çehreli
Is the following cast legal with dmd 2.040? struct MyChar { dchar d; this(dchar param) in { assert(false); // not called } body { d = param; assert(d != param); // not called } this(this) in { assert(false); // not

Re: When is array-to-array cast legal, and what does actually happen?

2010-02-22 Thread Daniel Keep
> ... > > I see that neither the constructor nor the postblit is called. > Apparently the bit representation is used. This has the risk of > violating struct invariants. > > Is it legal? > > Thank you, > Ali cast is to value conversions what a tactical nuclear strike is to peaceful negotiations

Re: When is array-to-array cast legal, and what does actually happen?

2010-02-22 Thread Ali Çehreli
Daniel Keep wrote: >> ... >> >> I see that neither the constructor nor the postblit is called. >> Apparently the bit representation is used. This has the risk of >> violating struct invariants. >> >> Is it legal? >> >> Thank you, >> Ali > > cast is to value conversions what a tactical nuclear stri

Re: When is array-to-array cast legal, and what does actually happen?

2010-02-23 Thread Lars T. Kyllingstad
Daniel Keep wrote: ... I see that neither the constructor nor the postblit is called. Apparently the bit representation is used. This has the risk of violating struct invariants. Is it legal? Thank you, Ali cast is to value conversions what a tactical nuclear strike is to peaceful negotiatio

Re: When is array-to-array cast legal, and what does actually happen?

2010-02-23 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ali Çehreli wrote: > Daniel Keep wrote: >>> ... > Well I forget the details, but it's been pointed out before that D's cast is fundamentally broken. You get one cast operator that hides the full set of c++ static, dynamic, const & reinterpret casts.

Re: When is array-to-array cast legal, and what does actually happen?

2010-02-24 Thread bearophile
Daniel Keep: > [1] Except for int<->float. Oh, and objects. Really, this is one thing > I could just about strangle K&R for: conflating value-preserving, > non-value-preserving *AND* unsafe conversions all into a single > construct. Walter, gets slapped with a fish for not putting a bullet in >