Thread overview
[Issue 24018] array concatenation doesn't work with disabled default construction
Jun 27, 2023
FeepingCreature
Jun 27, 2023
Teodor Dutu
Jun 27, 2023
Dlang Bot
Jun 27, 2023
Dlang Bot
Jun 27, 2023
Dlang Bot
June 27, 2023
https://issues.dlang.org/show_bug.cgi?id=24018

--- Comment #1 from FeepingCreature <default_357-line@yahoo.de> ---
I think the underlying problem is maybe actually that `.length =` does default construction. There is no way to change length at once without "constructing" the target memory, but that's what `_d_arraycatnTX` requires.

--
June 27, 2023
https://issues.dlang.org/show_bug.cgi?id=24018

Teodor Dutu <teodor.dutu@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |teodor.dutu@gmail.com

--- Comment #2 from Teodor Dutu <teodor.dutu@gmail.com> ---
The old hook was using `__arrayAlloc()` and `__setArrayAllocLength()` to
allocate the resulting array. I am trying to move them to core.lifetime.d as
templates now as part of https://github.com/dlang/dmd/pull/15299. After this,
I'll update `_d_arraycatnTX()` to use them instead of `.length = ...`.

I can't just import them from rt.lifetime.d to core.lifetime.d because the build system doesn't allow this dependency. And core.lifetime.d is never compiled, so it can only contain templates. I gave more details about this issue in this post: https://github.com/dlang/dmd/pull/15299

--
June 27, 2023
https://issues.dlang.org/show_bug.cgi?id=24018

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@FeepingCreature created dlang/dmd pull request #15352 "CHANGE: Make `array.length = n` `@system` if default construction is disabled on the array type (fixes 24018)" fixing this issue:

- Fix issue 24018: make `array.length = n` `@system` if default construction is
disabled on the array type.
  This is needed as there is otherwise no good way to resize an array of
non-constructable elements in user code at all.

https://github.com/dlang/dmd/pull/15352

--
June 27, 2023
https://issues.dlang.org/show_bug.cgi?id=24018

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@FeepingCreature created dlang/dmd pull request #15354 "Fix issue 24018: set length manually via runtime function." fixing this issue:

- Fix issue 24018: make `array.length = n` `@system` if default construction is
disabled on the array type.
  This is needed as there is otherwise no good way to resize an array of
non-constructable elements in user code at all.

- Fix issue 24018: instead of calling `array.length =`, call the runtime
function that implements `array.length =` instead.
  This skips the check for the element type being constructable, which is
correct because concatenation doesn't expose unconstructed memory anyway.

https://github.com/dlang/dmd/pull/15354

--
June 27, 2023
https://issues.dlang.org/show_bug.cgi?id=24018

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #15354 "Fix issue 24018: set length manually via runtime function." was merged into master:

- f17d270cacabbb192c9f01a2aecd10e1389fcf8e by Mathis Beer:
  Fix issue 24018: make `array.length = n` `@system` if default construction is
disabled on the array type.
  This is needed as there is otherwise no good way to resize an array of
non-constructable elements in user code at all.

- e37e3f18844494166ac3b68f2b5b6bf450867712 by Mathis Beer:
  Fix issue 24018: instead of calling `array.length =`, call the runtime
function that implements `array.length =` instead.
  This skips the check for the element type being constructable, which is
correct because concatenation doesn't expose unconstructed memory anyway.

https://github.com/dlang/dmd/pull/15354

--