Bug 19645 – Default parameters not checked for @safe

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Other
Creation time
2019-02-04T01:36:20Z
Last change time
2022-07-16T08:00:04Z
Keywords
accepts-invalid, pull, safe
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=11048

Comments

Comment #0 by bugzilla — 2019-02-04T01:36:20Z
Reported by ag0aep6g: import std.stdio; @safe: immutable x = 42; void main() { *f() = 7; writeln(x); // 42 writeln(*&x); // 7 } int* f(int* y = cast(int*) &x) { return y; }
Comment #1 by dfj1esp02 — 2019-02-04T11:05:09Z
Also: --- shared int b; pure void g(int a=b){} pure void f() { g(); } ---
Comment #2 by razvan.nitu1305 — 2019-02-26T15:48:35Z
(In reply to anonymous4 from comment #1) > Also: > --- > shared int b; > pure void g(int a=b){} > pure void f() > { > g(); > } > --- Existing violation in phobos : https://github.com/dlang/phobos/blob/master/std/path.d#L2741
Comment #3 by dfj1esp02 — 2019-02-28T08:55:58Z
relativePath is inferred as pure too
Comment #4 by dlang-bot — 2019-03-07T17:05:46Z
@RazvanN7 created dlang/dmd pull request #9428 " Fix Issue 19645 - Default parameters not checked for @safe" fixing this issue: - Fix Issue 19645 - Fix Issue 19645 - Fix Issue 19645 - Default parameters not checked for @safe https://github.com/dlang/dmd/pull/9428
Comment #5 by bugzilla — 2019-03-20T21:03:52Z
To be specific: ----- module m; shared int b; pure void g(int a=b){} ----- import m; int b; pure void f() { g(); } ----- should be compiled as if written: ----- module m; shared int b; pure void g(int a=b){} ----- import m; int b; pure void f() { g(m.b); // pick m.b, not local b } -----
Comment #6 by dlang-bot — 2019-03-20T22:03:18Z
@WalterBright created dlang/dlang.org pull request #2607 "fix Issue 19645 - Default parameters not checked for @safe" fixing this issue: - fix Issue 19645 - Default parameters not checked for @safe https://github.com/dlang/dlang.org/pull/2607
Comment #7 by bugzilla — 2019-03-20T22:04:00Z
Comment #8 by dlang-bot — 2019-03-21T23:50:31Z
dlang/dlang.org pull request #2607 "Function Default Parameters are underspecified" was merged into master: - 9100e8d3630f1f533167467989104f3f86846474 by Walter Bright: fix Issue 19645 - Default parameters not checked for @safe https://github.com/dlang/dlang.org/pull/2607
Comment #9 by ag0aep6g — 2019-03-22T01:12:00Z
Reopening. Walter's spec fix was merged, but that doesn't fix the issue in DMD.
Comment #10 by john.michael.hall — 2020-04-08T20:58:16Z
*** Issue 20726 has been marked as a duplicate of this issue. ***
Comment #11 by john.michael.hall — 2020-04-08T21:00:23Z
This is also an issue for __gshared default parameters and particularly auto ref __gshared parameters. See: https://issues.dlang.org/show_bug.cgi?id=20726
Comment #12 by ibuclaw — 2022-07-16T08:00:04Z
Although this is specifically for @safe, the broader issue is a duplicate of 11048. *** This issue has been marked as a duplicate of issue 11048 ***