------- 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