This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: egcs bug in c++ setw() ?


> 
> 
> 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 <iomanip.h>
> #include <iostream.h>
> #include <stdlib.h>
> 
> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]