[Issue 21210] New: std.traits : isAssignable false positive on disabled copy struct

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 30 14:01:45 UTC 2020


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

          Issue ID: 21210
           Summary: std.traits : isAssignable false positive on disabled
                    copy struct
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: pro.mathias.lang at gmail.com

The following code should either compile, or trigger the static assert:
```
import std.traits;

struct NC { @disable this(this); }

void main ()
{
    NC a, c;
    static assert(isAssignable!NC);
    c = NC();
    c = a;
}
```

Because `isAssignable` definition checks that both lvalues and rvalues can be
used.
However, on the lvalue assignment (`c = a`), the compiler errors out, even
though the `static assert` passed.

Found after https://github.com/dlang/phobos/pull/7609 was reverted.
I believe the reason for this is some aggressive const-folding on the compiler
side.

--


More information about the Digitalmars-d-bugs mailing list