dmd icon indicating copy to clipboard operation
dmd copied to clipboard

Default arguments bypass most attributes check (pure, @safe, @nogc)

Open dlangBugzillaToGithub opened this issue 12 years ago • 18 comments

Jonathan M Davis (@jmdavis) reported this on 2013-09-15T14:54:15Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=11048

CC List

  • Andrej Mitrovic (@AndrejMitrovic)
  • Walter Bright (@WalterBright)
  • Vladimir Panteleev (@CyberShadow)
  • Iain Buclaw (@ibuclaw)
  • Mathias LANG (@Geod24)

Description

int x = 7;

void foo() pure
{
    // Does not detect use of mutable global and compiles when it shouldn't.
    bar();

    // Correctly detects the use of a mutable global and gives an error
    baz(x);
}

void bar(int a = x) pure {}

void baz(int a) pure {}

void main() {}

dlangBugzillaToGithub avatar Sep 15 '13 14:09 dlangBugzillaToGithub