Skip to content

Commit 9decd49

Browse files
authored
Fix issue dlang#22517. typeid(void) claims that the type has pointers, so (dlang#22593)
hasIndirections should match.
1 parent 70c7655 commit 9decd49

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

druntime/src/core/internal/array/utils.d

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ void[] __arrayAlloc(T)(size_t arrSize) @trusted
157157
return null;
158158
}
159159

160+
// https://github.com/dlang/dmd/issues/22517
161+
@system unittest
162+
{
163+
auto arr = new void[10];
164+
assert((GC.getAttr(&arr[0]) & BlkAttr.NO_SCAN) == 0);
165+
}
166+
160167
/**
161168
Given an array of length `size` that needs to be expanded to `newlength`,
162169
compute a new capacity.

druntime/src/core/internal/traits.d

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,11 @@ template hasIndirections(T)
587587
else static if (__traits(isAssociativeArray, T) || is(T == class) || is(T == interface))
588588
enum hasIndirections = true;
589589
else static if (is(T == E[N], E, size_t N))
590-
enum hasIndirections = T.sizeof && (is(immutable E == immutable void) || hasIndirections!(BaseElemOf!E));
590+
enum hasIndirections = T.sizeof && hasIndirections!(BaseElemOf!E);
591591
else static if (isFunctionPointer!T)
592592
enum hasIndirections = false;
593+
else static if (is(immutable(T) == immutable(void)))
594+
enum hasIndirections = true;
593595
else
594596
enum hasIndirections = isPointer!T || isDelegate!T || isDynamicArray!T;
595597
}
@@ -750,11 +752,11 @@ template hasIndirections(T)
750752
// https://github.com/dlang/dmd/issues/20812
751753
@safe unittest
752754
{
753-
static assert(!hasIndirections!void);
754-
static assert(!hasIndirections!(const void));
755-
static assert(!hasIndirections!(inout void));
756-
static assert(!hasIndirections!(immutable void));
757-
static assert(!hasIndirections!(shared void));
755+
static assert( hasIndirections!void);
756+
static assert( hasIndirections!(const void));
757+
static assert( hasIndirections!(inout void));
758+
static assert( hasIndirections!(immutable void));
759+
static assert( hasIndirections!(shared void));
758760

759761
static assert( hasIndirections!(void*));
760762
static assert( hasIndirections!(const void*));

0 commit comments

Comments
 (0)