This repository was archived by the owner on Oct 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed
Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -705,6 +705,20 @@ nothrow pure @safe unittest
705705 enum ctfe_works = (() => { Month x = Month.jan; return toUbyte (x).length > 0 ; })();
706706}
707707
708+ @trusted pure nothrow @nogc
709+ const (ubyte )[] toUbyte (T)(const ref T val) if (is (T == delegate ) || is (T : V* , V) && __traits(getAliasThis, T).length == 0 )
710+ {
711+ if (__ctfe)
712+ {
713+ if (val ! is null ) assert (0 , " Unable to compute byte representation of non-null pointer at compile time" );
714+ return ctfe_alloc (T.sizeof);
715+ }
716+ else
717+ {
718+ return (cast (const (ubyte )* )&val)[0 .. T.sizeof];
719+ }
720+ }
721+
708722package (core.internal ) bool isNonReference(T)()
709723{
710724 static if (is (T == struct ) || is (T == union ))
Original file line number Diff line number Diff line change 11void main ()
22{
3- hashOfVoidPtrArray ();
3+ issue19562 ();
44 issue15111();
55 issues16654And16764();
66 issue18918();
@@ -15,11 +15,15 @@ void main()
1515 pr2243();
1616}
1717
18- // / Check that ` hashOf` can be called on an array of void pointers.
19- void hashOfVoidPtrArray () @nogc nothrow pure @system
18+ // / Check hashOf an array of void pointers or delegates is @safe .
19+ void issue19562 () @nogc nothrow pure @safe
2020{
21- void * [] val;
22- const _ = hashOf(val); // Check a PR doesn't break this.
21+ void * [10 ] val;
22+ size_t h = hashOf(val[]);
23+
24+ alias D = void delegate ();
25+ D[10 ] ds;
26+ h = hashOf(ds[]);
2327}
2428
2529// / hashOf was failing for structs that had an `alias this` to a dynamic array.
You can’t perform that action at this time.
0 commit comments