summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-10-30 10:14:23 +0200
committerGitHub <noreply@github.com>2021-10-30 10:14:23 +0200
commit2bda4a30a6b12dd0840dc347e454e54fe26721e7 (patch)
tree710080e3b5d35981eb2a01c76855eb93a5afb785
parentf755e452d2a2c7656f07793b7f01dc654a7c5253 (diff)
downloadNim-2bda4a30a6b12dd0840dc347e454e54fe26721e7.tar.gz
fixes #19000 (#19032)
* fixes #19000

* progress
-rw-r--r--lib/system/memalloc.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/system/memalloc.nim b/lib/system/memalloc.nim
index f8ebc8c5f..49766e69d 100644
--- a/lib/system/memalloc.nim
+++ b/lib/system/memalloc.nim
@@ -116,6 +116,9 @@ 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 =
@@ -141,6 +144,9 @@ 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 =