D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20211 - should be set appropriate version for enabled DIPs (in command lines)
Summary: should be set appropriate version for enabled DIPs (in command lines)
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-13 10:57 UTC by a11e99z
Modified: 2020-03-20 06:30 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description a11e99z 2019-09-13 10:57:46 UTC
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 anonymous4 2019-09-16 09:11:17 UTC
Try this:

template A()
{
int[] f(scope int[] a) @safe
{
    return a;
}
}

static assert(!__traits(compiles,A!()));
Comment 2 a11e99z 2019-09-16 10:09:39 UTC
(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 Walter Bright 2020-03-20 06:30:59 UTC
The workaround looks sufficient.