[Issue 13781] Tuple assign should be @nogc
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Dec 14 18:55:20 PST 2014
https://issues.dlang.org/show_bug.cgi?id=13781
Kenji Hara <k.hara.pg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|DMD |Phobos
Hardware|x86 |All
OS|Windows |All
--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to Peter Alexander from comment #1)
> Adding @nogc to Tuple.opAssign gives:
>
> Error: @nogc function 'std.typecons.Tuple!(string,
> "s").Tuple.opAssign!(Tuple!(string, "s")).opAssign' cannot call non- at nogc
> function 'std.algorithm.swap!(Tuple!string).swap'
>
> Adding @nogc to swap makes the code compile.
>
> Both are templates, so @nogc should be inferred. Marking this as a DMD bug.
This is a little problem in Phobos code.
'swap' is used from the opAssign template function in Tuple, but swap checks
(hasElaborateAssign!T || !isAssignable!T) and it would see the signature of
T.opAssign. On mutual function calls, attributes are inferred as non- at nogc by
default. It's a design so this is not a compiler bug.
The correct fix is to mark std.algorithm.swap function as @nogc.
--
More information about the Digitalmars-d-bugs
mailing list