Assigning a rand() value to a vector element and then accessing the element seems to negate setw() - no spaces are added to the output. I attempted to access the element via iterators as well as integer subscripts, neither caused any change. The console reported no errors or warnings during compile.
----------- g++ -v output ------------ Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7) ---------------------- Sample File --------------- #include <iomanip> #include <iostream> #include <vector> #include <cstdlib> using namespace std; void showVector(vector<int> &v); int main() { vector<int> v(100); for(int i=0; i <v.size(); i++) { v[i] = rand(); } showVector(v); } void showVector(vector<int> &v) { //------------------------------------------------------ // Display elements of a vector, 10 per line //------------------------------------------------------ vector<int> ::iterator p ; int count=0 ; for(p=v.begin(); p!=v.end(); p++) { cout << setw(6) << *p ; count = (count+1)%10 ; if( count==0 ) cout << endl ; } cout << endl ; } -- Summary: rand() combined with vectors negates setw() Product: gcc Version: 4.2.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pmaconi at gmail dot com GCC build triplet: x86_64-linux-gnu GCC host triplet: x86_64-linux-gnu GCC target triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36178