This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: optimization/4130: gcc 3.0 -O2 and printf optimization
- From: Richard Kettlewell <rjk at greenend dot org dot uk>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 3 Apr 2002 10:36:01 -0000
- Subject: Re: optimization/4130: gcc 3.0 -O2 and printf optimization
- Reply-to: Richard Kettlewell <rjk at greenend dot org dot uk>
The following reply was made to PR optimization/4130; it has been noted by GNATS.
From: Richard Kettlewell <rjk@greenend.org.uk>
To: rth@gcc.gnu.org,
gcc-bugs@gcc.gnu.org,
gcc-prs@gcc.gnu.org,
nobody@gcc.gnu.org,
gcc-gnats@gcc.gnu.org
Cc:
Subject: Re: optimization/4130: gcc 3.0 -O2 and printf optimization
Date: Wed, 3 Apr 2002 11:25:54 +0100
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