www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17996] New: [Reg 2.077] getopt fails to recognize argument

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

          Issue ID: 17996
           Summary: [Reg 2.077] getopt fails to recognize argument
           Product: D
           Version: D2
          Hardware: x86
                OS: FreeBSD
            Status: NEW
          Severity: regression
          Priority: P3
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

cat > bug.d << CODE
import std.getopt;

void main(string[] args)
{
    string extras;
    getopt(args, "extras", &extras);
}
CODE
dmd bug
./bug --extras=foobar

==========

std.getopt.GetOptException /home/vagrant/dlang/dmd-2.077.0/freebsd/bin32/../../src/phobos/std/getopt.d(789):
Unrecognized option --extras=foobar
----------------
??:?  safe void std.getopt.getoptImpl!().getoptImpl(ref immutable(char)[][],
ref std.getopt.configuration, ref std.getopt.GetoptResult, ref
std.getopt.GetOptException, void[][immutable(char)[]],
void[][immutable(char)[]]) [0x807b950]
??:?  safe void std.getopt.getoptImpl!(immutable(char)[],
immutable(char)[]*).getoptImpl(ref immutable(char)[][], ref
std.getopt.configuration, ref std.getopt.GetoptResult, ref
std.getopt.GetOptException, void[][immutable(char)[]],
void[][immutable(char)[]], immutable(char)[], immutable(char)[]*) [0x8079eed]
??:?  safe std.getopt.GetoptResult std.getopt.getopt!(immutable(char)[],
immutable(char)[]*).getopt(ref immutable(char)[][], immutable(char)[],
immutable(char)[]*) [0x8079942]
??:? _Dmain [0x80798db]

==========

I've debugged this until a failing optMatch call with seemingly correct
arguments.
https://github.com/dlang/phobos/blob/7a2732e4b06d6684a717a756c20e271e9ede2812/std/getopt.d#L842

When converting optMatch to a template the bug goes away, so it might be some
incompatibilities with the pre-compiled binary function shipped with
phobos-2.077.0.

--
Nov 20 2017