D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19846 - zero size function parameter such as byte[0] causes code to not be executed
Summary: zero size function parameter such as byte[0] causes code to not be executed
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords: backend, pull, wrong-code
Depends on:
Blocks:
 
Reported: 2019-05-05 18:28 UTC by andy-hanson
Modified: 2020-09-03 09:31 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description andy-hanson 2019-05-05 18:28:07 UTC
```
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 Nicholas Wilson 2019-05-22 00:40:46 UTC
This is DMD specific, LDC behaves fine.
Comment 2 Dlang Bot 2020-09-02 08:30:10 UTC
@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 Dlang Bot 2020-09-03 09:31:39 UTC
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