Possible runtime bug in preprocessing of command line arguments passed to the D main
Basile B.
b2.temp at gmx.com
Sun Oct 24 14:21:52 UTC 2021
The following code, on linux
```d
module runnable;
extern(C) int execv(const char* p, const char** args);
immutable src = `
import std.getopt;
void main(string[] args)
{
bool c;
getopt(args, "c", &c);
}
`;
void prepareProgram()
{
import std.process : execute;
import std.file : write;
write("a.d", src);
execute(["dmd", "a.d"]);
}
void main(string[] args)
{
prepareProgram();
execv("a", null);
}
```
results in a std.getopt exception:
> object.Exception@/usr/include/dmd/phobos/std/getopt.d(423):
> Invalid arguments string passed: program name missing
Context is a program not written in D that uses execv to call a D
program that uses getopt.
What do you think ?
More information about the Digitalmars-d-learn
mailing list