[Issue 22614] Wrong copy constructor is called depending on context

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 21 10:51:03 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22614

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

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

--- Comment #1 from RazvanN <razvan.nitu1305 at gmail.com> ---
It seems that for some reason annotating with @safe the unittest enables the
compiler to infer attributes for the nested struct members. This has the result
of inferring pure for the copy constructors and therefore the immutable
constructor becomes a unique constructor (which means it can be implicitly
convertible to mutable). Next, the compiler thinks that the unique copy
constructor is better than const copy constructor.

I think that the fundamental problem here is that @safe enables attribute
inference. I haven't seen this anywhere explicitly stated in the spec.

The unique conversion rules are another black box for me.

--


More information about the Digitalmars-d-bugs mailing list