D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19180 - Expose dmd.mtype.Type.isZeroInit as __traits(isZeroInit, T)
Summary: Expose dmd.mtype.Type.isZeroInit as __traits(isZeroInit, T)
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-20 01:38 UTC by Nathan S.
Modified: 2021-01-03 22:57 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Nathan S. 2018-08-20 01:38:15 UTC
It's useful to identify at compile time types with 0 initializers. Doing this with CTFE and templates is slow and memory-hungry[1] and runs into errors[2][3]. The compiler already has its own check for this that we can expose instead.

Proposed syntax is `__traits(isZeroInit, T)` where the second argument must resolve to the type T itself instead of being any expression whose result is an instance of T. This would be to prevent someone from mistakenly thinking he can use `__traits(isInitZero, x)` to test whether some variable `x` was explicitly initialized as zero.

[1] https://github.com/dlang/phobos/pull/6537
[2] https://github.com/dlang/phobos/pull/6670#issuecomment-414111649
[3] https://github.com/dlang/phobos/pull/6461
Comment 1 Nathan S. 2018-08-20 01:57:22 UTC
Pull request: https://github.com/dlang/dmd/pull/8583
Comment 2 github-bugzilla 2018-09-08 20:08:58 UTC
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/6983b0b071f8cb495639f62382e8658ddde03d77
Fix Issue 19180 - Expose dmd.mtype.Type.isZeroInit as __traits(isZeroInit, T)

https://github.com/dlang/dmd/commit/6d067b0084cfffb7c76c936b8af335373b565adf
Merge pull request #8583 from n8sh/isZeroInit-19180

Fix Issue 19180 - Expose dmd.mtype.Type.isZeroInit as __traits(isZeroInit, T)
merged-on-behalf-of: Razvan Nitu <RazvanN7@users.noreply.github.com>
Comment 3 github-bugzilla 2018-09-09 17:08:13 UTC
Commits pushed to master at https://github.com/dlang/dlang.org

https://github.com/dlang/dlang.org/commit/5183de7809b7d5367e0b444f0c423f77e6e97a67
Update spec for Issue 19180 - Expose... __traits(isZeroInit, T)

This is the companion of https://github.com/dlang/dmd/pull/8583

https://github.com/dlang/dlang.org/commit/826ea94809d870328bd98d9aeac2472b657d0c49
Merge pull request #2450 from n8sh/isZeroInit-19180

Update spec for Issue 19180 - Expose... __traits(isZeroInit, T)
merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>
Comment 4 Dlang Bot 2021-01-03 22:57:19 UTC
dlang/dmd pull request #12093 "[dmd-cxx] Backport more recent traits to the C++ port" was merged into dmd-cxx:

- c480509b0f455c8dc86c70752d55e517ca3d7416 by Nathan Sashihara:
  [dmd-cxx] Fix Issue 19180 - Expose dmd.mtype.Type.isZeroInit as __traits(isZeroInit, T)

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