Bug 19846 – zero size function parameter such as byte[0] causes code to not be executed

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2019-05-05T18:28:07Z
Last change time
2020-09-03T09:31:39Z
Keywords
backend, pull, wrong-code
Assigned to
No Owner
Creator
andy.pj.hanson

Comments

Comment #0 by andy.pj.hanson — 2019-05-05T18:28:07Z
``` import core.stdc.stdio : printf; alias Void = byte[0]; static immutable byte[0] VOID = []; Void print() { printf("This should print"); return VOID; } Void identity(Void value) { return value; } void main() { identity(print()); } ``` Running this program should print "This should print", but instead nothing happens. The program works if `identity(print())` is replaced with just `print()`.
Comment #1 by iamthewilsonator — 2019-05-22T00:40:46Z
This is DMD specific, LDC behaves fine.
Comment #2 by dlang-bot — 2020-09-02T08:30:10Z
@WalterBright created dlang/dmd pull request #11668 "fix Issue 19846 - zero size function parameter such as byte[0] causes…" fixing this issue: - fix Issue 19846 - zero size function parameter such as byte[0] causes code to not be executed https://github.com/dlang/dmd/pull/11668
Comment #3 by dlang-bot — 2020-09-03T09:31:39Z
dlang/dmd pull request #11668 "fix Issue 19846 - zero size function parameter such as byte[0] causes…" was merged into master: - 4d196e962efa62a2dd8788a04e47a41f99ca9de5 by Walter Bright: fix Issue 19846 - zero size function parameter such as byte[0] causes code to not be executed https://github.com/dlang/dmd/pull/11668