* Revert "fixes #19000 (#19032)"
This reverts commit 2bda4a30a6.
* fixes #20516; add testcase
This commit is contained in:
parent
e83f27e6a0
commit
5e4dd571d4
2 changed files with 7 additions and 6 deletions
|
|
@ -116,9 +116,6 @@ when hasAlloc and not defined(js):
|
||||||
##
|
##
|
||||||
## See also:
|
## See also:
|
||||||
## * `create <#create,typedesc>`_
|
## * `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))
|
cast[ptr T](alloc(T.sizeof * size))
|
||||||
|
|
||||||
template alloc0*(size: Natural): pointer =
|
template alloc0*(size: Natural): pointer =
|
||||||
|
|
@ -144,9 +141,6 @@ when hasAlloc and not defined(js):
|
||||||
##
|
##
|
||||||
## The allocated memory belongs to its allocating thread!
|
## The allocated memory belongs to its allocating thread!
|
||||||
## Use `createShared <#createShared,typedesc>`_ to allocate from a shared heap.
|
## 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))
|
cast[ptr T](alloc0(sizeof(T) * size))
|
||||||
|
|
||||||
template realloc*(p: pointer, newSize: Natural): pointer =
|
template realloc*(p: pointer, newSize: Natural): pointer =
|
||||||
|
|
|
||||||
|
|
@ -162,3 +162,10 @@ block:
|
||||||
reset(y)
|
reset(y)
|
||||||
doAssert y.b == {}
|
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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue