Bug 13907 – Surrogate pairs in wchar string literal will cause incorrect length match

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-12-29T01:54:00Z
Last change time
2015-02-18T03:41:35Z
Keywords
accepts-invalid, pull, rejects-valid
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2014-12-29T01:54:38Z
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); }
Comment #1 by k.hara.pg — 2014-12-29T01:57:01Z
Comment #2 by github-bugzilla — 2014-12-31T05:15:52Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/6d732186da6e8255e26879e0bc57a40433810389 fix Issue 13907 - Surrogate pairs in wchar string literal will cause incorrect length match Stop considering lengthen conversion in StringExp::implicitConvTo(). https://github.com/D-Programming-Language/dmd/commit/4e21e5639fd2e11bc993043121393f512f4043bd Merge pull request #4222 from 9rnsr/fix13907 Issue 13907 - Surrogate pairs in wchar string literal will cause incorrect length match
Comment #3 by github-bugzilla — 2015-02-18T03:41:35Z
Commits pushed to 2.067 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/6d732186da6e8255e26879e0bc57a40433810389 fix Issue 13907 - Surrogate pairs in wchar string literal will cause incorrect length match https://github.com/D-Programming-Language/dmd/commit/4e21e5639fd2e11bc993043121393f512f4043bd Merge pull request #4222 from 9rnsr/fix13907