Bug 19408 – nothrow inference fails (template + postblit)

Status
RESOLVED
Resolution
WONTFIX
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-11-17T11:51:34Z
Last change time
2021-02-24T14:56:19Z
Assigned to
No Owner
Creator
Stanislav Blinov

Comments

Comment #0 by stanislav.blinov — 2018-11-17T11:51:34Z
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(); }()); }
Comment #1 by stanislav.blinov — 2018-11-17T14:01:28Z
Looks like this one is a bit of a roller-coaster: --- 8< --- Up to 2.062 : Failure with output: onlineapp.d(15): Error: static assert (!true) is false 2.063 : Failure with output: ----- onlineapp.d(29): Error: sneak.get is not nothrow onlineapp.d(28): Error: delegate onlineapp.main.__lambda3 '__lambda3' is nothrow yet may throw ----- 2.064 to 2.066.0: Failure with output: ----- onlineapp.d(29): Error: 'onlineapp.Infidel!(S).Infidel.get' is not nothrow onlineapp.d(28): Error: delegate 'onlineapp.main.__lambda4' is nothrow yet may throw ----- 2.067.1 to 2.070.2: Failure with output: onlineapp.d(18): Error: static assert (is(typeof(__error))) is false 2.071.2: Failure with output: ----- onlineapp.d(18): Error: static assert (is(typeof([snip]))) is false ----- Since 2.072.2: Success and no output --- 8< --- It seems like 2.063 to 2.066 exerted expected behavior.
Comment #2 by bugzilla — 2018-12-13T05:52:47Z
Postblit is likely to be supplanted with copy constructors in the near future.
Comment #3 by razvan.nitu1305 — 2021-02-24T14:56:19Z
Postblit is no longer maintained as its fundamental flaws cannot be fixed, so this is not going to get fixed. Please update the code to use the copy constructor. Closing as WONRFIX.