December 29, 2014 [Issue 13907] New: Surrogate pairs in wchar string literal will cause incorrect length match | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=13907 Issue ID: 13907 Summary: Surrogate pairs in wchar string literal will cause incorrect length match Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: accepts-invalid, rejects-valid Severity: normal Priority: P1 Component: DMD Assignee: nobody@puremagic.com Reporter: k.hara.pg@gmail.com Example code: void f1(wchar[1] a) {} void f2(wchar[2] a) {} void f3(wchar[3] a) {} auto f12(wchar[1]) { return 1; } auto f12(wchar[2]) { return 2; } void main() { // Surrogate pair is used for U+10000 wstring s = "\U00010000"w; assert(s.length == 2); // ok f2("\U00010000"w); f2("\U00010000"); // Why the wstring length == 2 matches to wchar[1]? f1("\U00010000"w); f1("\U00010000" ); // Why the wstring length == 2 matches to wchar[3]? f3("\U00010000"w); f3("\U00010000" ); // This is ok, but... assert(f12("ab"w) == 2); // I think the wchar[2] version should be selected, but doesn't. assert(f12("\U00010000"w) == 2); } -- |
Copyright © 1999-2021 by the D Language Foundation