Bug 19582 – Make core.internal.convert.toUbyte in CTFE for arrays work with reference type elements and not call postblits/dtors
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-01-14T09:13:06Z
Last change time
2020-09-11T16:02:54Z
Assigned to
No Owner
Creator
Nathan S.
Comments
Comment #0 by n8sh.secondary — 2019-01-14T09:13:06Z
Make `core.internal.convert.toUbyte` in CTFE for arrays work with reference type elements and not call postblits/dtors. This is necessary for the CTFE path of `hashOf` in some circumstances.
Example currently non-compiling code:
---
import core.internal.convert : toUbyte;
final static class C : Object {}
enum b1 = (() @nogc nothrow pure @safe { C[10] o; return toUbyte(o[])[0]; })();
static struct S
{
int x;
@disable this(this);
~this() @nogc nothrow
{
import core.stdc.stdio : puts;
if (x) puts("impure");
}
}
enum b2 = () {
S[10] a;
return ((const S[] a) @nogc nothrow pure @safe => toUbyte(a))(a);
}();
---
Comment #1 by n8sh.secondary — 2019-01-14T09:18:13Z