Skip to content

Commit 00ff84c

Browse files
authored
Fix memory allocation failed regression introduced by #22766 (#23776)
1 parent a1544f7 commit 00ff84c

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

compiler/src/dmd/dinterpret.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2907,7 +2907,8 @@ public:
29072907
for (ClassDeclaration c = cd; c; c = c.baseClass)
29082908
totalFieldCount += c.fields.length;
29092909

2910-
totalFieldCount -= cd.hasMonitor(); // skip __monitor field
2910+
if (totalFieldCount)
2911+
totalFieldCount -= cd.hasMonitor(); // skip __monitor field
29112912

29122913
auto elems = new Expressions(totalFieldCount);
29132914
ptrdiff_t fieldsSoFar = totalFieldCount;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
TEST_OUTPUT:
3+
---
4+
C22766()
5+
---
6+
*/
7+
module object;
8+
9+
class C22766 { }
10+
11+
pragma(msg, new C22766);

0 commit comments

Comments
 (0)