Bug 20211 – should be set appropriate version for enabled DIPs (in command lines)

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-09-13T10:57:46Z
Last change time
2020-03-20T06:30:59Z
Assigned to
No Owner
Creator
a11e99z

Comments

Comment #0 by black80 — 2019-09-13T10:57:46Z
my library should be compiled with command option -dip1000 but I cann't to determine it in static assert. memory corruption can occur without it. static assert at CT is better than random crashed application. for future when u add option to compiler for any DIP please add appropriate version too. if such version exists then update documentation too https://dlang.org/spec/version.html#predefined-versions
Comment #1 by dfj1esp02 — 2019-09-16T09:11:17Z
Try this: template A() { int[] f(scope int[] a) @safe { return a; } } static assert(!__traits(compiles,A!()));
Comment #2 by black80 — 2019-09-16T10:09:39Z
(In reply to anonymous4 from comment #1) > > Try this: > > template A() { > int[] f(scope int[] a) @safe { return a; } > } > static assert(!__traits(compiles,A!())); thank you. current workaround: template isDip1000EnabledImpl() { private template A() { int[] f( scope int[] a) @safe { return a; } } public enum isDip1000EnabledImpl = !__traits( compiles, A!()); } alias isDip1000Enabled = isDip1000EnabledImpl!();
Comment #3 by bugzilla — 2020-03-20T06:30:59Z
The workaround looks sufficient.