www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21592] New: two stack traces if high surrogate is printed

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

          Issue ID: 21592
           Summary: two stack traces if high surrogate is printed
           Product: D
           Version: D2
          Hardware: Other
                OS: Other
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: kdevel vogtner.de

```unpsur.d
import std.stdio: writeln;
import std.utf: byCodeUnit;

void main ()
{
   wstring w = "\U00010400";
   wchar wc = w.byCodeUnit [0]; // take high surrogate
   writeln (wc);                // let it throw a UTFException
}
```

Application output

std.utf.UTFException std/stdio.d(2910): unpaired surrogate UTF-16 value
----------------
??:?  safe void std.stdio.File.LockingTextWriter.highSurrogateShouldBeEmpty()
[0x5616f092907f]
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d:2992  safe void
std.stdio.File.LockingTextWriter.put!(char).put(char) [0x5616f0922407]
/dlang/dmd/linux/bin64/../../src/phobos/std/range/primitives.d:277  safe void
std.range.primitives.doPut!(std.stdio.File.LockingTextWriter, char).doPut(ref
std.stdio.File.LockingTextWriter, ref char) [0x5616f09223ea]
/dlang/dmd/linux/bin64/../../src/phobos/std/range/primitives.d:380  safe void
std.range.primitives.put!(std.stdio.File.LockingTextWriter, char).put(ref
std.stdio.File.LockingTextWriter, char) [0x5616f09223bf]
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d:1567  safe void
std.stdio.File.write!(wchar, char).write(wchar, char) [0x5616f0921bfe]
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d:3911  safe void
std.stdio.writeln!(wchar).writeln(wchar) [0x5616f0921b82]
onlineapp.d:8 _Dmain [0x5616f0921736]
std.utf.UTFException std/stdio.d(2910): unpaired surrogate UTF-16 value
----------------
??:?  safe void std.stdio.File.LockingTextWriter.highSurrogateShouldBeEmpty()
[0x5616f092907f]
??:?  trusted void std.stdio.File.LockingTextWriter.__dtor() [0x5616f0929197]
??:?  trusted void std.stdio.File.LockingTextWriter.__aggrDtor()
[0x5616f09291f0]
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d:1541  safe void
std.stdio.File.write!(wchar, char).write(wchar, char) [0x5616f0921c1d]
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d:3911  safe void
std.stdio.writeln!(wchar).writeln(wchar) [0x5616f0921b82]
onlineapp.d:8 _Dmain [0x5616f0921736]

expected: only one trace

--
Jan 29