Thread overview
[Issue 15425] std.traits.hasIndirections fails to recognize nested structs
Aug 31, 2017
RazvanN
Aug 31, 2017
Marc Schütz
Nov 17, 2020
Nathan S.
Nov 17, 2020
Dlang Bot
Nov 18, 2020
Dlang Bot
Sep 14
Dlang Bot
August 31, 2017
https://issues.dlang.org/show_bug.cgi?id=15425

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> ---
Maybe I am getting this wrong, but both S1 and S2 are free of indirections for as far as I can tell. Even if the sizeof includes the context pointer, it is not a user defined part of the struct.

hasIndirections does the following for structs:

static if (is(T == struct) || is(T == union))
    enum hasIndirections = anySatisfy!(.hasIndirections, FieldTypeTuple!T);

As you can see, all the field types are tested (the context pointer is not an actual field of the struct), so in my opinion the output of your program is correct.

--
August 31, 2017
https://issues.dlang.org/show_bug.cgi?id=15425

--- Comment #2 from Marc Schütz <schuetzm@gmx.net> ---
(In reply to RazvanN from comment #1)
> Maybe I am getting this wrong, but both S1 and S2 are free of indirections for as far as I can tell. Even if the sizeof includes the context pointer, it is not a user defined part of the struct.
> 
> hasIndirections does the following for structs:
> 
> static if (is(T == struct) || is(T == union))
>     enum hasIndirections = anySatisfy!(.hasIndirections, FieldTypeTuple!T);
> 
> As you can see, all the field types are tested (the context pointer is not an actual field of the struct), so in my opinion the output of your program is correct.

hasIndirections is used (among other things) to check whether a memory allocation needs to be registered with the GC (e.g. in RefCounted), or whether an object can be safely sent to another thread (e.g. hasUnsharedAliasing). For these purposes, it is crucial that it checks _all_ indirections, not just the explicitly declared ones.

In std.traits, there is a whole bunch of helper traits like hasRawAliasing, hasRawUnsharedAliasing, hasAliasing with partially overlapping functionality. I don't know what each one is supposed to be used for; maybe hasIndirections actually does what it should. But if so, then it's clearly used wrongly in other places (e.g. RefCounted).

--
November 17, 2020
https://issues.dlang.org/show_bug.cgi?id=15425

Nathan S. <n8sh.secondary@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |n8sh.secondary@hotmail.com
                 OS|Linux                       |All

--
November 17, 2020
https://issues.dlang.org/show_bug.cgi?id=15425

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@n8sh created dlang/phobos pull request #7696 "Fix Issue 15425 - std.traits.hasIndirections fails to recognize nested structs" fixing this issue:

- Fix Issue 15425 - std.traits.hasIndirections fails to recognize nested structs

https://github.com/dlang/phobos/pull/7696

--
November 18, 2020
https://issues.dlang.org/show_bug.cgi?id=15425

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/phobos pull request #7696 "Fix Issue 15425 - std.traits.hasIndirections fails to recognize nested structs" was merged into master:

- d6c0c3430ae2faead57bae19ab76488eca0ece64 by Nathan Sashihara:
  Fix Issue 15425 - std.traits.hasIndirections fails to recognize nested
structs

https://github.com/dlang/phobos/pull/7696

--
September 14
https://issues.dlang.org/show_bug.cgi?id=15425

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/druntime pull request #3568 "Backport Fix Issue 15425 to druntime" was merged into master:

- 89e206333d10c3b224951a088c6bf34f06ac3d04 by RazvanN7:
  Backport Fix Issue 15425 to druntime

https://github.com/dlang/druntime/pull/3568

--