public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/25120]  New: [3.4/4.0/4.1/4.2] builtin printf/fprintf is confused by -fexec-charset
@ 2005-11-27 15:50 ghazi at gcc dot gnu dot org
  2005-11-27 15:52 ` [Bug middle-end/25120] " ghazi at gcc dot gnu dot org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: ghazi at gcc dot gnu dot org @ 2005-11-27 15:50 UTC (permalink / raw)
  To: gcc-bugs

With a program compiled with e.g. -O2 -fexec-charset=IBM1047, the builtin
handlers for printf and fprintf get confused because they check for matching
stuff in the format string like "%s", "%s\n", "%c" and trailing "\n" using the
host's charset values.  So they don't match correctly when compiling strings in
the target charset and thus fail to do the appropriate transformations.  This
is merely a slight pessimization.

However what's worse is they'll do incorrect transformations if the user's
program happens to have matching strings.  E.g.

  printf ("hello world\012");

In the above, "\012" is ascii "\n" but it's something else in other charsets. 
However, GCC will still transform this call into puts with the "\012" stripped
off.  This yields "wrong code".


-- 
           Summary: [3.4/4.0/4.1/4.2] builtin printf/fprintf is confused by
                    -fexec-charset
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code, missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ghazi at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25120


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2006-09-16 16:32 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-27 15:50 [Bug middle-end/25120] New: [3.4/4.0/4.1/4.2] builtin printf/fprintf is confused by -fexec-charset ghazi at gcc dot gnu dot org
2005-11-27 15:52 ` [Bug middle-end/25120] " ghazi at gcc dot gnu dot org
2005-11-27 16:11 ` [Bug middle-end/25120] " pinskia at gcc dot gnu dot org
2005-11-27 16:59 ` ghazi at gcc dot gnu dot org
2005-11-27 17:01 ` [Bug middle-end/25120] builtin *printf handlers are " ghazi at gcc dot gnu dot org
2005-11-27 22:45 ` ghazi at gcc dot gnu dot org
2005-11-28  0:45 ` joseph at codesourcery dot com
2005-11-28  2:45 ` ghazi at gcc dot gnu dot org
2005-11-28  3:36 ` ghazi at gcc dot gnu dot org
2005-11-29  5:17 ` ghazi at gcc dot gnu dot org
2005-11-29  5:18 ` ghazi at gcc dot gnu dot org
2005-11-29  5:18 ` ghazi at gcc dot gnu dot org
2005-12-04 16:23 ` ghazi at gcc dot gnu dot org
2005-12-04 17:07 ` gdr at integrable-solutions dot net
2005-12-07  3:54 ` ghazi at gcc dot gnu dot org
2006-02-05 21:40 ` pinskia at gcc dot gnu dot org
2006-09-16 16:32 ` kalium at gmx dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).