From mboxrd@z Thu Jan 1 00:00:00 1970 From: hjl@lucon.org (H.J. Lu) To: weimer@wrw3.resnet.cornell.edu (Westley Weimer) Cc: egcs@cygnus.com Subject: Re: egcs bug in c++ setw() ? Date: Wed, 03 Dec 1997 16:29:00 -0000 Message-id: References: X-SW-Source: 1997-12/msg00216.html > > > The last two (at least) versions of pgcc / egcs produce executables with > strange setw() behavior. setw() does set the output width, but its > argument overwrites whatever was going to be written next. > > Here's an condensed example that demonstrates the problem: > --- begin testing.cc --- > #include > #include > #include > > int main(void) > { > int i; > cout << endl << "The numbers 0 through 9 using setw(3):" << endl; > for (i = 0 ; i <= 9 ; i++) > cout << setw(3) << i; > cout << endl; > cout << "The numbers 0 through 9 using \" \" to separate:" << endl; > for (i = 0 ; i <= 9 ; i++) > cout << " " << i; > cout << endl << endl; > return(0); > } > --- end testing.cc --- > > Here's the output on various systems: > > turing% uname -a > SunOS turing.csuglab.cornell.edu 5.5 Generic_103093-03 sun4m sparc > SUNW,SPARCsystem-600 > ... > Reading specs from > /usr/local/gnu/gcc-2.7.2/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2/specs > gcc version 2.7.2 > > turing% a.out > The numbers 0 through 9 using setw(3): > 0 1 2 3 4 5 6 7 8 9 > The numbers 0 through 9 using " " to separate: > 0 1 2 3 4 5 6 7 8 9 > > Everything seems fine. Using egcs on i586/linux: > > merentha:/tmp$ uname -a > Linux wrw3 2.1.63 #7 Fri Nov 21 16:57:09 EST 1997 i586 unknown > ... > Reading specs from > /usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.06/specs > gcc version egcs-2.90.06 970907 (gcc2-970802 experimental) > merentha:/tmp$ a.out > The numbers 0 through 9 using setw(3): > 3 3 3 3 3 3 3 3 3 3 > The numbers 0 through 9 using " " to separate: > 0 1 2 3 4 5 6 7 8 9 > > That looks bad. Let's try again on the same computer using a more recent > version of pgcc/egcs. > > Reading specs from > /usr/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.17p/specs > gcc version egcs-2.90.17p 971114 (gcc2-970802 experimental) > merentha:/tmp$ a.out > The numbers 0 through 9 using setw(3): > 3 3 3 3 3 3 3 3 3 3 > The numbers 0 through 9 using " " to separate: > 0 1 2 3 4 5 6 7 8 9 > Your test case runs fine on my linux/x86 with libc 5.4.41. H.J.