www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15488] New: global variable shadows function argument


          Issue ID: 15488
           Summary: global variable shadows function argument
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: or weka.io


module abc;
int global_x = 0;


void foo(int global_x) {
    import std.stdio;
    writefln("Address of func argument: %x", &global_x);
    import abc;
    writefln("Address of func argument: %x", &global_x);

void main() {


rdmd main.d

Address of func argument: 7fff56108688
Address of func argument: 7fb0c9c04c70

If I move the import outside of 'foo' the function argument silently shadows
the global variable, which seems fine to me.

Dec 31 2015