diff --git a/lib/system/memalloc.nim b/lib/system/memalloc.nim index 879a1f06616c..a61e335f481c 100644 --- a/lib/system/memalloc.nim +++ b/lib/system/memalloc.nim @@ -116,9 +116,6 @@ when hasAlloc and not defined(js): ## ## See also: ## * `create <#create,typedesc>`_ - static: - when sizeof(T) <= 0: - {.fatal: "createU does not support types T where sizeof(T) == 0".} cast[ptr T](alloc(T.sizeof * size)) template alloc0*(size: Natural): pointer = @@ -144,9 +141,6 @@ when hasAlloc and not defined(js): ## ## The allocated memory belongs to its allocating thread! ## Use `createShared <#createShared,typedesc>`_ to allocate from a shared heap. - static: - when sizeof(T) <= 0: - {.fatal: "create does not support types T where sizeof(T) == 0".} cast[ptr T](alloc0(sizeof(T) * size)) template realloc*(p: pointer, newSize: Natural): pointer = diff --git a/tests/stdlib/tsystem.nim b/tests/stdlib/tsystem.nim index a90a1d1d9f29..786e7a432b42 100644 --- a/tests/stdlib/tsystem.nim +++ b/tests/stdlib/tsystem.nim @@ -101,3 +101,10 @@ block: reset(y) doAssert y.b == {} +block: # bug #20516 + type Foo = object + x {.bitsize:4.}: uint + y {.bitsize:4.}: uint + + when not defined(js): + let a = create(Foo)