[Issue 19408] New: nothrow inference fails (template + postblit)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Nov 17 11:51:34 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19408
Issue ID: 19408
Summary: nothrow inference fails (template + postblit)
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: stanislav.blinov at gmail.com
struct Infidel(T) {
T value;
T get() { return value; } // returns a copy
}
void main() {
static struct S {
int x;
this(this) {
if (x > 0) throw new Exception("fail");
else x = 1;
}
}
// passes, cannot nothrow-copy
static assert(!is(typeof(() nothrow { S* x; union U { S x; } U u = U(*x);
})));
// passes, copy may throw
static assert(is(typeof(() { S* x; union U { S x; } U u = U(*x); })));
S s;
auto sneak = Infidel!S(s); // won't throw here, s.x was 0
// fails but shouldn't:
static assert(!is(typeof(() nothrow { auto x = sneak.get(); })));
import std.exception;
// compiles (but shouldn't), and passes:
assertThrown(() nothrow {
auto x = sneak.get();
}());
}
--
More information about the Digitalmars-d-bugs
mailing list