[Issue 19568] New: hashOf should not unnecessarily call a struct's fields' postblits & dtors in CTFE
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jan 9 16:51:12 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19568
Issue ID: 19568
Summary: hashOf should not unnecessarily call a struct's
fields' postblits & dtors in CTFE
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: n8sh.secondary at hotmail.com
Example of code that doesn't work because a CTFE-only path in hashOf
unnecessarily calls an impure destructor and tries to call a disabled postblit:
---
void main()
{
static struct S1
{
@disable this(this);
~this() @nogc nothrow
{
import core.stdc.stdio;
if (mptr) puts("impure");
}
size_t[2] pad;
void* mptr;
}
static struct S2
{
@disable this(this);
~this() @nogc nothrow
{
import core.stdc.stdio;
if (fd != -1) puts("impure");
}
int fd = -1;
S1 s1;
}
static struct S3
{
private S2 s2;
}
S3 s3;
size_t h = ((ref S3 s3) pure => hashOf(s3))(s3);
}
---
--
More information about the Digitalmars-d-bugs
mailing list