[Issue 15459] stdin.byLine.each!(map!somefunc) compiles, fails to link with ld

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Dec 18 09:47:43 PST 2015


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

ZombineDev <petar.p.kirov at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |petar.p.kirov at gmail.com

--- Comment #1 from ZombineDev <petar.p.kirov at gmail.com> ---
When you're iterating any kind of string (char, wchar or dchar based) the
element type is always dchar. This special case for narrow strings (UTF-8 and
UTF-16) is also known as UTF autodecoding. You can see this for yourself if you
change `somefunc` into a template and add a pragma statement to make the
compiler emit an information message about the type of `c` for each
instantiation of the function:

auto somefunc(C)(C c)
{
    pragma (msg, C);
    return c;
}

See also: http://dlang.org/phobos/std_range_primitives.html#.ElementType,
http://dlang.org/phobos/std_range_primitives.html#.front and
http://dlang.org/glossary.html#narrow strings

This is still a valid bug report, because the compiler should refuse to compile
this code.

--


More information about the Digitalmars-d-bugs mailing list