The function call duplocale (LC_GLOBAL_LOCALE) crashes.
According to POSIX
it should instead return a duplicate copy of the global locale.
How to reproduce:
Compile and run the attached program.
1) POSIX says that LC_GLOBAL_LOCALE is "a special locale object descriptor",
and the argument of duplocale has to be "a locale object" without further
2) The POSIX specification of newlocale says "The results are undefined if
the base argument is the special locale object LC_GLOBAL_LOCALE" but similar
wording is not present in the POSIX specification of duplocale.
3) The call works fine on MacOS X 10.5.
4) POSIX does not foresee any other way to create a copy of the global locale
than through duplocale:
newlocale (LC_ALL_MASK, "", LC_GLOBAL_LOCALE)
has undefined behaviour, and
newlocale (LC_ALL_MASK, nl_langinfo (_NL_LOCALE_NAME (LC_COLLATE)), NULL)
uses API that is specific to glibc, not present in POSIX.
Created attachment 4389 [details]
Fixed in duplocale.
But it is completely irrelevant what macos does. The specification is written
to follow the glibc implementation.