Why do some T.init evaluate to true while others to false?

Marc Schütz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 31 02:47:02 PDT 2016


On Monday, 30 May 2016 at 19:06:53 UTC, ArturG wrote:
> does this count?
>
> struct Foo
> {
>     int x;
>     float f;
> }
>
> void main()
> {
>     Foo foo;
>     if(foo is typeof(foo).init) "A: does'nt work".writeln;
>     foo = Foo();
>     if(foo is typeof(foo).init) "B: works".writeln;
> }

This one is a bug in DMD. It works correctly with LDC.

`Foo()` is supposed to be identical to `Foo.init`.

File here:
https://issues.dlang.org/show_bug.cgi?id=16105


More information about the Digitalmars-d-learn mailing list