[Issue 13541] std.windows.syserror.sysErrorString() should be nothrow

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Sep 28 02:46:41 PDT 2014


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

--- Comment #4 from Vladimir Panteleev <thecybershadow at gmail.com> ---
(In reply to Walter Bright from comment #0)
> This should be an assert because:
> 
> 1. sysErrorString()'s argument should ONLY be values returned by Windows
> APIs like GetLastError(), and so this should always succeed.

No, it may fail. Windows exposes a SetLastError API, which allows setting error
codes which may not be valid. Third-party libraries may use SetLastError to set
the error code to a private one, which sysErrorString may fail to parse.

> 2. recursively calling sysErrorString() with the SAME value will cause a
> stack overflow crash, not any usable exception.

No, sysErrorString is not recursing "with the SAME value". It is recursing with
the value from FormatMessageW, which we can expect to be valid.

--


More information about the Digitalmars-d-bugs mailing list