D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7421 - std.getopt does not work with shared types
Summary: std.getopt does not work with shared types
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: bootcamp
Depends on:
Blocks:
 
Reported: 2012-02-01 12:55 UTC by Robert Clipsham
Modified: 2020-03-21 03:56 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Robert Clipsham 2012-02-01 12:55:01 UTC
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 Robert Clipsham 2012-02-16 07:00:10 UTC
It appears getopt() doesn't work with any shared types.
Comment 2 SomeDude 2012-04-20 00:53:59 UTC
See also issue 7526 and issue 7693