[Issue 18407] New: debug should escape nothrow @nogc safe (not just pure)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Feb 9 06:50:55 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18407
Issue ID: 18407
Summary: debug should escape nothrow @nogc safe (not just pure)
Product: D
Version: D2
Hardware: x86
OS: Mac OS X
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: timothee.cour2 at gmail.com
```
void fun_nogc()@nogc{
debug{
auto a1=new int(1); // Error: cannot use 'new' in @nogc function 'main.fun'
}
}
void fun_nothrow() nothrow{
debug{
static int a;
import std.exception;
enforce(a==0); // Error: function std.exception.enforce!(Exception,
bool).enforce is not nothrow
}
}
static int temp(){
static int a=0;
a++;
return a;
}
int fun_pure() pure{
int ret;
debug{
ret+=temp; // ok this works
static int a2=0;
a2++;
ret+=a2;
}
return ret;
}
void fun_safe() @safe{
debug{
int []a=[1];
if(false) a.ptr[0]++; // Error: a.ptr cannot be used in @safe code, use
&a[0] instead
}
}
void main(){
fun_nogc;
fun_nothrow;
fun_pure;
fun_safe;
}
```
--
More information about the Digitalmars-d-bugs
mailing list