optimization/4130: gcc 3.0 -O2 and printf optimization
Richard Kettlewell
rjk@greenend.org.uk
Wed Apr 3 02:29:00 GMT 2002
rth@gcc.gnu.org writes:
> Synopsis: gcc 3.0 -O2 and printf optimization
>
> State-Changed-From-To: open->closed
> State-Changed-By: rth
> State-Changed-When: Wed Apr 3 00:20:49 2002
> State-Changed-Why:
> According to Uli Drepper, whom I consider an authority in this area:
>
> The handling of byte sequences which are not valid in the current locale
> is unspecified. Either result is valid. There is the different result
> but people writing incorrect code should not get into to way of
> optimizing code. And there always is the opportunity to compile with -O0.
>
> Although -fno-builtin-printf is certainly more palletable
> than -O0.
>
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4130
My copy of the draft standard says:
An encoding error occurs if the character sequence presented to
the underlying mbrtowc function does not form a valid
(generalized) multibyte character, or if the code value passed to
the underlying wcrtomb does not correspond to a valid
(generalized) multibyte character. The wide-character input/output
functions and the byte input/output functions store the value of
the macro EILSEQ in errno if and only if an encoding error occurs.
And:
The printf function returns the number of characters transmitted,
or a negative value if an output or encoding error occurred.
Granted this may have changed between the draft and the standard, but
it looks quite adequately specified to me.
ttfn/rjk
More information about the Gcc-bugs
mailing list