Thread overview
[Issue 11048] Default arguments bypass most attributes check (pure, @safe, @nogc)
Nov 09, 2020
Mathias LANG
Nov 09, 2020
Mathias LANG
Jul 16, 2022
Iain Buclaw
Jul 16, 2022
Iain Buclaw
Jul 16, 2022
Iain Buclaw
Jul 16, 2022
Dlang Bot
November 09, 2020
https://issues.dlang.org/show_bug.cgi?id=11048

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pro.mathias.lang@gmail.com
            Summary|Default arguments not taken |Default arguments bypass
                   |into account when being     |most attributes check
                   |called by pure functions    |(pure, @safe, @nogc)

--- Comment #3 from Mathias LANG <pro.mathias.lang@gmail.com> ---
This applies to all attributes but `nothrow`, but only because `nothrow` is the
very last to be checked.
E.g. this compiles:
```
int doit() { return 42; }
void f(int i = doit()) nothrow @safe pure @nogc {}
void main() /* nothrow */ @safe pure @nogc { f(); }
```

--
November 09, 2020
https://issues.dlang.org/show_bug.cgi?id=11048

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dlang-bugzilla@thecybershad
                   |                            |ow.net

--- Comment #4 from Mathias LANG <pro.mathias.lang@gmail.com> ---
*** Issue 13442 has been marked as a duplicate of this issue. ***

--
July 16, 2022
https://issues.dlang.org/show_bug.cgi?id=11048

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, safe
                 CC|                            |ibuclaw@gdcproject.org
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=19645
           Severity|normal                      |major

--
July 16, 2022
https://issues.dlang.org/show_bug.cgi?id=11048

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #5 from Iain Buclaw <ibuclaw@gdcproject.org> ---
*** Issue 19645 has been marked as a duplicate of this issue. ***

--
July 16, 2022
https://issues.dlang.org/show_bug.cgi?id=11048

--- Comment #6 from Iain Buclaw <ibuclaw@gdcproject.org> ---
I just encountered this when reviewing some @safe code in the dmd compiler implementation.


The crux of which boils down to:
```
int findCondition() @system;

int parseGeneric(int param = findCondition()) @safe
{
    return param;
}

int parseSpec() @safe
{
    return parseGeneric(); // Compiles!
}
```

Call the function directly in @safe code, and you get the expected error.

--
July 16, 2022
https://issues.dlang.org/show_bug.cgi?id=11048

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
@ibuclaw created dlang/dmd pull request #14309 "fix Issue 11048 - Default arguments bypass most attributes check (pure, @safe, @nogc)" fixing this issue:

- fix Issue 11048 - Default arguments bypass most attributes check (pure,
@safe, @nogc)

https://github.com/dlang/dmd/pull/14309

--
December 13
https://issues.dlang.org/show_bug.cgi?id=11048

--- Comment #8 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18670

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--