Extra .tupleof field in structs with disabled postblit blocks non-GC-allocation trait
Meta
jared771 at gmail.com
Wed May 9 21:09:12 UTC 2018
On Wednesday, 9 May 2018 at 18:04:40 UTC, Per Nordlöw wrote:
> On Wednesday, 9 May 2018 at 17:52:48 UTC, Meta wrote:
>> I wasn't able to reproduce it on dmd-nightly:
>> https://run.dlang.io/is/9wT8tH
>>
>> What version of the compiler are you using?
>
> Ahh, the struct needs to be in a unittest block for it to
> happen:
>
> struct R
> {
> @disable this(this);
> int* _ptr;
> }
> unittest
> {
> struct S
> {
> @disable this(this);
> int* _ptr;
> }
> struct T
> {
> int* _ptr;
> }
> pragma(msg, "R: ", typeof(R.tupleof));
> pragma(msg, "S: ", typeof(S.tupleof));
> pragma(msg, "T: ", typeof(T.tupleof));
> }
>
> prints
>
> R: (int*)
> S: (int*, void*)
> T: (int*)
>
> Why is that?
It's a context pointer to the enclosing function/object/struct.
Mark the struct as static to get rid of it.
More information about the Digitalmars-d-learn
mailing list