[Issue 2789] Functions overloads are not checked for conflicts

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Jun 14 01:02:17 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=2789

Rob T <alanb at ucora.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alanb at ucora.com

--- Comment #15 from Rob T <alanb at ucora.com> ---
This bug report may be related or a duplicate
https://issues.dlang.org/show_bug.cgi?id=13283

The problem persists in dmd v2.067.1

It is particularly nasty since even the linker won't catch it in some cases.

For example:

main_lib.d 
---------------------------
module main_lib;
import std.stdio;
alias t_TaskFunction = void function();

// duplicate overloads that should not compile

void Task(){
   writeln("A");
}

void Task(){
   writeln("B");
}


main.d
---------------------------
import main_lib;

int main()
{
   t_TaskFunction TaskFunction = &Task; // ???
   TaskFunction();
   return 0;
}

$dmd main_lib.d -lib -O -oflibmain_lib.a
$dmd main2.d -O -L-L./ -L-lmain_lib -ofmain
$./main

Output is "A" on my system.

--


More information about the Digitalmars-d-bugs mailing list