Bug 23035 – -preview=rvaluerefparam causes @system function to be @safe

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-04-18T12:46:05Z
Last change time
2022-09-09T18:44:49Z
Keywords
accepts-invalid, safe
Assigned to
No Owner
Creator
Atila Neves

Comments

Comment #0 by atila.neves — 2022-04-18T12:46:05Z
Related to https://issues.dlang.org/show_bug.cgi?id=20869, which added this test to druntime: ------------- @system unittest { static struct S { void opPostMove(const ref S old) nothrow @system { __gshared int i; new int(i++); // Force @gc impure @system } } alias T = void function() @system nothrow; static assert(is(typeof({ S s; move(s); }) == T)); static assert(is(typeof({ S s; move(s, s); }) == T)); } ------------ If druntime tests are compiled with -preview=rvalueparam, the first static assert fails, since now that function is considered @safe for some reason.
Comment #1 by stanislav.blinov — 2022-04-18T15:41:59Z
That assert fails for me regardless of -preview setting. Probably because opPostMove decayed from the source and isn't actually being used. Which would make `move(s)` @safe @nogc nothrow pure. (IMHO, it should just stay that way. Introduction of proper move ctors would be much more preferable to maintaining that ad-hoc crutch).
Comment #2 by atila.neves — 2022-04-19T06:52:09Z
That's... weird, especially since that assert is part of the druntime test suite.
Comment #3 by atila.neves — 2022-09-09T18:44:49Z
I can no longer reproduce this.