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
705
705
enum ctfe_works = (() => { Month x = Month.jan; return toUbyte (x).length > 0 ; })();
706
706
}
707
707
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
+
708
722
package (core.internal ) bool isNonReference(T)()
709
723
{
710
724
static if (is (T == struct ) || is (T == union ))
Original file line number Diff line number Diff line change 1
1
void main ()
2
2
{
3
- hashOfVoidPtrArray ();
3
+ issue19562 ();
4
4
issue15111();
5
5
issues16654And16764();
6
6
issue18918();
@@ -15,11 +15,15 @@ void main()
15
15
pr2243();
16
16
}
17
17
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
20
20
{
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[]);
23
27
}
24
28
25
29
// / 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