This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/21982] GCC should combine adjacent stdio calls
- From: "dnovillo at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Jun 2005 13:15:30 -0000
- Subject: [Bug tree-optimization/21982] GCC should combine adjacent stdio calls
- References: <20050609125653.21982.ghazi@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From dnovillo at redhat dot com 2005-06-10 13:15 -------
Subject: Re: GCC should combine adjacent stdio calls
On Thu, Jun 09, 2005 at 07:52:42PM -0000, joseph at codesourcery dot com wrote:
> > > extern char *s;
> > > extern int i;
> > >
> > > printf("%d", i);
> > > printf("%.5s", s);
> > >
> > > you can't merge the printf calls because the first one could have changed
> > > what is pointed to by s.
> > >
> > How can printing an integer to stdout affect 's'? Unless 's' has
> > been somehow mapped to stdout's buffer? Is that what you have in
> > mind?
>
> (a) It could be stdio's buffer (via setvbuf).
>
> (b) It could be a glibc memory stream opened with fmemopen (if the user
> assigned to stdout - which glibc allows - or you do this optimization on
> fprintf and not just printf).
>
> (c) It could point to a memory mapping of the file being written.
>
Good lord. To me this is a pathological case. I'd wager that
this happens approximately never. How about a switch disabling
stdio merging?
Diego.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21982