On Sat, Feb 24, 2018 at 10:31:55AM +0100, Bruno Haible wrote: > Hi, > > On Alpine Linux 3.7.0, which uses musl libc, the gnulib test 'test-getopt-posix' > fails. To me, this looks like a POSIX compliance bug of musl. > Find attached a reduced test case. > > $ gcc foo.c -Wall > $ ./a.ou t > foo.c:134: assertion 'options[0] == ':' || ((options[0] == '-' || options[0] == '+') && options[1] == ':')' failed > > Reference: POSIX > http://pubs.opengroup.org/onlinepubs/9699919799/functions/getopt.html It seems like the behavior you're claiming is wrong is that getopt is treating ':' in the optstring as a valid option rather than just a modifier to the option character before it or the special flag at the beginning of optstring. The likely reason the bug exists is that the spec isn't clear that colons can't be option characters (maybe they could be, especially if they're not initial or immediately following another option character?) but it is clear that characters outside class alnum are not required to be supported as options, and I think it's clear that accepting -: is not the right thing to do here. Attached patch should fix it; if nobody objects right away I'll apply. Thanks! Rich