gcc4[1.7] printf treats differently a string constant and a character array

Andy Koppe andy.koppe@gmail.com
Tue Dec 29 13:30:00 GMT 2009


2009/12/29 Eric Blake:
>> I couldn't find specific text about invalid bytes in the POSIX printf
>> spec,
>
> http://www.opengroup.org/onlinepubs/9699919799/functions/fprintf.html
>
> "all forms of fprintf() shall fail if:
>
> [EILSEQ]
>    [CX] A wide-character code that does not correspond to a valid
> character has been detected."

The issue wasn't with wide characters, but invalid multibyte chars.
But anyway, we're agreed that printf is right to bail out.


> Remember, POSIX states that any use in a character context of bytes with
> the 8th-bit set is specifically undefined in the C locale (whether that be
> C.ASCII or C.UTF-8).

I very much disagree with that. C.ASCII and C.UTF-8 are different
locales from plain "C", and the whole point of the explicitly stated
charset is to define the meaning of bytes beyond 7-bit ASCII.

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list