Bug 7421 – std.getopt does not work with shared types

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-01T12:55:01Z
Last change time
2020-03-21T03:56:34Z
Keywords
bootcamp
Assigned to
No Owner
Creator
Robert Clipsham

Comments

Comment #0 by robert — 2012-02-01T12:55:01Z
When using the following: ---- import std.getopt; shared string foo; void main(string[] args) { getopt(args, "foo", &foo); } ---- Then using: $ dmd test.d $ ./test --foo=bar std.conv.ConvException@/home/robert/.dvm/compilers/dmd-2.056/bin/../src/phobos/std/conv.d(1749): Can't convert value `oo' of type string to type immutable(char) ---------------- ./test(immutable(char) std.conv.toImpl!(immutable(char), immutable(char)[]).toImpl(immutable(char)[])+0x43) [0x80671c3] ./test(immutable(char) std.conv.to!(immutable(char)).to!(immutable(char)[]).to(immutable(char)[])+0xe) [0x80670a2] ./test(void std.getopt.handleOption!(shared(immutable(char)[])*).handleOption(immutable(char)[], shared(immutable(char)[])*, ref immutable(char)[][], ref std.getopt.configuration, bool)+0x393) [0x8066f13] ./test(void std.getopt.getoptImpl!(immutable(char)[], shared(immutable(char)[])*).getoptImpl(ref immutable(char)[][], ref std.getopt.configuration, immutable(char)[], shared(immutable(char)[])*)+0x90) [0x8066b00] ./test(void std.getopt.getopt!(immutable(char)[], shared(immutable(char)[])*).getopt(ref immutable(char)[][], immutable(char)[], shared(immutable(char)[])*)+0x35) [0x8066a1d] ./test(_Dmain+0x1d) [0x80669e1] ./test(extern (C) int rt.dmain2.main(int, char**).void runMain()+0x14) [0x8069a90] ./test(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate())+0x1d) [0x8069735] ./test(extern (C) int rt.dmain2.main(int, char**).void runAll()+0x37) [0x8069ad7] ./test(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate())+0x1d) [0x8069735] ./test(main+0x94) [0x80696e4] /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x60c113] ---------------- Removing the shared qualifier removes the issue. Tested with dmd 2.056 and dmd-master on Linux x86-32.
Comment #1 by robert — 2012-02-16T07:00:10Z
It appears getopt() doesn't work with any shared types.
Comment #2 by lovelydear — 2012-04-20T00:53:59Z
See also issue 7526 and issue 7693