[Issue 463] New: private module members have global bindings instead of local ones

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 26 03:09:22 PDT 2006


http://d.puremagic.com/issues/show_bug.cgi?id=463

           Summary: private module members have global bindings instead of
                    local ones
           Product: D
           Version: 0.170
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: link-failure
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: thomas-dloop at kuehne.cn


http://www.digitalmars.com/d/attribute.html
> Private means that only members of the enclosing class can access
> the member, or members and functions in the same module as the
> enclosing class. Private members cannot be overridden. Private
> module members are equivalent to static declarations in C programs.

=== d.d ===
private void foo(){
}
======

dmd -c d.d
readelf -s d.o
> Symbol table '.symtab' contains 11 entries:
> Num:    Value  Size Type    Bind   Vis      Ndx Name
<snip>
>  10: 00000000     5 FUNC    GLOBAL DEFAULT   12 _D1a3fooFZv

=== c.c ===
static void foo(){
}
======

gcc -c c.c
readelf -s c.o
> Symbol table '.symtab' contains 11 entries:
> Num:    Value  Size Type    Bind   Vis      Ndx Name
<snip>
>   5: 00000000     6 FUNC    LOCAL  DEFAULT    1 foo


This becomes a problem if a private function with C calling convention
is defined:

=== bug.d ===
private extern(C) void foo(){
}
======

dmd -c bug.d
> Symbol table '.symtab' contains 11 entries:
>   Num:    Value  Size Type    Bind   Vis      Ndx Name
<snip>
> 10: 00000000     5 FUNC    GLOBAL DEFAULT   12 foo

The last line should have been
> 10: 00000000     5 FUNC     LOCAL DEFAULT   12 foo


-- 




More information about the Digitalmars-d-bugs mailing list