Bug 20726 – @safe function can modify __gshared data if passed as ref parameter default value

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-04-08T20:02:02Z
Last change time
2020-04-08T20:58:16Z
Assigned to
No Owner
Creator
JR

Comments

Comment #0 by zorael — 2020-04-08T20:02:02Z
Manjaro/Arch x86_64, dmd v2.091.0 but also all dmd compilers v2.060 up to current on run.dlang.io. This passes and __gshared `gshared` is modified by `foo`. ``` __gshared int gshared = 42; void foo(ref int i = gshared) @safe { ++i; } void main() { assert(gshared == 42); foo(); assert(gshared == 43); } ```
Comment #1 by john.michael.hall — 2020-04-08T20:58:16Z
This was originally brought up here https://forum.dlang.org/thread/[email protected] with respect to __gshared default function parameters by themselves. It seems as if this is a duplicate of https://issues.dlang.org/show_bug.cgi?id=19645 *** This issue has been marked as a duplicate of issue 19645 ***