Bug 19180 – Expose dmd.mtype.Type.isZeroInit as __traits(isZeroInit, T)

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-08-20T01:38:15Z
Last change time
2021-01-03T22:57:19Z
Assigned to
No Owner
Creator
Nathan S.

Comments

Comment #0 by n8sh.secondary — 2018-08-20T01:38:15Z
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 by n8sh.secondary — 2018-08-20T01:57:22Z
Comment #2 by github-bugzilla — 2018-09-08T20:08:58Z
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 <[email protected]>
Comment #3 by github-bugzilla — 2018-09-09T17:08:13Z
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 <[email protected]>
Comment #4 by dlang-bot — 2021-01-03T22:57:19Z
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