[Issue 6888] std.getopt.getopt: one-letter hash option causes range violation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 3 09:58:37 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6888



--- Comment #1 from Maksim Zholudev <maximzms at gmail.com> 2011-11-03 09:58:06 PDT ---
The bug is found!

In std/getopt.d:

If the option is not long and bundling is forbidden lines 587-588 are executed.
If arg looks like "-t" value is empty but !value is false, i.e. in the
following code all asserts are true:

test.d:
--------------------
void main()
{
    string s = "t";
    string s1 = s[1..$];
    string s2 = null;

    assert(s1 == null);
    assert(s2 == null);
    assert(!s1 == false); // Why?
    assert(!s2 == true);
}
--------------------

Hence in std/getopt.d in the line 464:
!val is false and val is empty when we come to line 519 and try to access its
contents.

I'm going to fix it right now.
But the behavior of empty slices looks like a bug of the compiler.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list