Thread overview
[Issue 463] New: private module members have global bindings instead of local ones
Oct 26, 2006
d-bugmail
[Issue 463] [module] private module members have global bindings instead of local ones
Jan 22, 2013
Andrej Mitrovic
October 26, 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@digitalmars.com
        ReportedBy: thomas-dloop@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


-- 

November 26, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=463


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei@metalanguage.com
         AssignedTo|nobody@puremagic.com        |bugzilla@digitalmars.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 22, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=463


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-22 11:06:44 PST ---
I could be wrong, but I don't think that "equivalent to static" meant it's equivalent in how the two are emitted to the object, but rather where they can be used from (i.e. from within a single module).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------