www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Bug 144] New: Alias and function names fail to collide

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=144

           Summary: Alias and function names fail to collide
           Product: D
           Version: 0.156
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: shro8822 uidaho.edu


When a function and an alias have the same name, DMD fails to produce an error
unless the function is used directly. Taking the address off the name give no
error.

In the following test case the function (not the alias) is arbitrarily picked,
however it is also the first definition and if this follows the pattern set in
bug #52, reversing the order of the definitions will change this (not checked).

Test case:
-------------
void fn(){assert(0);}   // make a function

void gm(){assert(0);}   // make another function

alias gm fn;            // alias the second with the name of the first

void main()
{                       // make pointer-to-function from name
        void function() fnp = & fn;
                        // call pointer-to-function
        fnp();

        // fn();        // wont compile with this line included
}
-------------


-- 
May 17 2006
parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail puremagic.com schrieb am 2006-05-18:
 When a function and an alias have the same name, DMD fails to produce an error
 unless the function is used directly. Taking the address off the name give no
 error.

 In the following test case the function (not the alias) is arbitrarily picked,
 however it is also the first definition and if this follows the pattern set in
 bug #52, reversing the order of the definitions will change this (not checked).

Added to DStress as http://dstress.kuehne.cn/nocompile/a/alias_35_A.d http://dstress.kuehne.cn/nocompile/a/alias_35_B.d http://dstress.kuehne.cn/nocompile/a/alias_35_C.d http://dstress.kuehne.cn/nocompile/a/alias_35_D.d http://dstress.kuehne.cn/nocompile/a/alias_35_E.d http://dstress.kuehne.cn/nocompile/a/alias_35_F.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEbcjD3w+/yD4P9tIRAn+JAJ4nA+Q/c4pQkhSoY5+masDI8sYHCwCgkROO nJgMRGSwQ9zzFPElpY8GC+k= =Zv6L -----END PGP SIGNATURE-----
May 19 2006