* John Scott:

> #define _POSIX_C_SOURCE 200809L
> #include <assert.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> int main(int argc, char *argv[]) {
>       int opt;
>       while((opt = getopt(argc, argv, "a:")) != -1) {}
>       assert(optarg != NULL);
> }
>
> If this is invoked as './a.out -afoo', the inner assertion will
> the last assertion will fail with glibc.

POSIX leaves it unspecified if optarg is changed if getopt returns -1.
Only optind must be left unchanged.  I do not think this is a glibc
bug (or a musl bug).

Reply via email to