D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3245 - Easy bug fix available for disabled unit test code in std.encoding
Summary: Easy bug fix available for disabled unit test code in std.encoding
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 trivial
Assignee: Andrei Alexandrescu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-11 21:59 UTC by Michael Rynn
Modified: 2015-06-09 01:28 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Michael Rynn 2009-08-11 21:59:39 UTC
Bug: unittest line 55 in std.encoding was disabled by version(none)

Rationale: Re-enabling unittest at line 55 results in failure. 

Fix: At line 1059  inside template EncoderInstance(CharType : char). 

Current version:

    dchar decodeReverseViaRead()()

    {

        auto c = read;
....


Fixed version:
    dchar decodeReverseViaRead()()
    {
        dchar c = read;
....

Its obvious after failure point is pinned, even if not knowing the exact specs, as decodeReverseViaRead must return a dchar, and variable c accumulates left shifted bits in the loop, same as the nearby safeDecodeViaRead method. In UTF-8,the auto c = read makes a char type only (thank you zerobugs debugger), so high bits put in c are thrown away, and function may return character 0. Re-enabled unittest code ran succesfully after above fix.
Comment 1 Andrei Alexandrescu 2009-08-12 00:23:37 UTC
Terrific, thanks. I looked at that and couldn't figure the problem.
Comment 2 Andrei Alexandrescu 2009-08-28 12:43:36 UTC
Thanks for the precise instructions.