On 30 April 2015 at 04:41, Steven Schveighoffer via Digitalmars-d <[email protected]> wrote: > On 4/29/15 4:29 AM, Iain Buclaw via Digitalmars-d wrote: >> >> On 29 April 2015 at 06:38, Steven Schveighoffer via Digitalmars-d >> <[email protected]> wrote: >>> >>> FYI, Andrei and Walter are reversing this change barring any new evidence >>> it's helpful to people. Please speak up if you disagree. >>> >>> >>> https://github.com/D-Programming-Language/dmd/pull/2885#issuecomment-97299912 >>> >> >> I disagree, and I would extend my thoughts to say that I don't think >> that the change is enough. We should also be warning on delegates and >> associative arrays too! >> >> if (arr) // Implicitly converted to (arr.ptr | arr.length) != 0 > > if(arr) simply means if(arr.ptr) != 0. Length does not come into play. >
https://github.com/D-Programming-Language/dlang.org/pull/981#commitcomment-10918439 The two mov's followed by an 'or' suspiciously look like (.ptr | .length) to me. >> if (dg) // Implicitly converted to (dg.ptr | dg.funcptr) != 0 > > > I don't know if I've ever expected that, you sure that's true? I would > actually expect if(dg) to be equivalent to if(dg.funcptr). I have no idea > how a dg would have a null pointer but valid funcptr. > Yes, it does (it emits the same assembly as arrays). >> if (aa) // Implicitly converted to (aa.ptr != null) > > > This is easily fixed when we fix aa to be a library type. We don't need > compiler help to fix this issue (we do need compiler help to remove AA > specialty code from the compiler, but once it's out, we can fix this without > effort). > It's still annoying to have to special-case non-scalar types in boolean contexts. The front-end should do this lowering. :-) https://github.com/D-Programming-GDC/GDC/blob/e9bfc0332e42d01402aeb2063d38fc5ea4e12fea/gcc/d/d-codegen.cc#L605 Iain.
