Comment 2 for bug 1718668

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

The tests checks that argv isn't touched by getopt.
There are multiple calls which work before the breaking one:

The calls set different options:
setenv ("POSIXLY_CORRECT", "1", 1);
Works
then
unsetenv ("POSIXLY_CORRECT");
fails

In this env getopt_loop moves the args around:
(gdb) p argv
$14 = {0x555555559c14 "program", 0x555555559d3d "donald", 0x555555559cd9 "-p", 0x555555559d44 "billy", 0x555555559d4a "duck",
  0x555555559c1c "-a", 0x555555559c1f "bar", 0x0, 0x555555559cc9 "foo", 0x555555559cdc "-q"}
(gdb) n
753 ASSERT (strcmp (argv[0], "program") == 0);
(gdb) p argv
$15 = {0x555555559c14 "program", 0x555555559cd9 "-p", 0x555555559d44 "billy", 0x555555559c1c "-a", 0x555555559d3d "donald",
  0x555555559d4a "duck", 0x555555559c1f "bar", 0x0, 0x555555559cc9 "foo", 0x555555559cdc "-q"}