[Issue 19966] [DIP1000] DIP1000 with a template behaves differently
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 13 09:26:47 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=19966
--- Comment #2 from Jacob Carlborg <doob at me.com> ---
(In reply to Walter Bright from comment #1)
> > 2. I think the above code is actually valid because it's not provable that `foo` escapes a pointer to the internal state of `Foo`
>
> It's not valid because foo() is defined as returning a pointer that is
> equivalent to foo()'s `this` pointer. Then, `a = f.foo;` is treated as
> assigning the address of `f` to `a`, a global, which is an error. The
> compiler is behaving correctly for this point.
So it doesn't matter if "foo" is returning something else, like a global
variable?
--
More information about the Digitalmars-d-bugs
mailing list