[Issue 11990] map don't play nice with default values in function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 25 10:52:25 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=11990


Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
          Component|Phobos                      |DMD
           Severity|major                       |critical


--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2014-01-25 10:52:21 PST ---
Reduced test case.

void main()
{
    test("abcdefg");
}

void test(string str)
{
    void bar(string sstr, size_t end = str.length-1)
    {
        import std.stdio;
        writeln(sstr.length, " ", end);
    }

    foo!(bar)(str[0..4]);
}

void foo(alias fun)(string s)
{
    fun(s);
}

Prints:
4 4294967295

The second parameter 'end' is assigned garbage because 'str' parameter of test
function is not directly accessible from 'foo' function.

Raised importance to 'critical' because it's wrong-code generation bug.

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


More information about the Digitalmars-d-bugs mailing list