[Bug c++/36178] New: rand() combined with vectors negates setw()

2008-05-07 Thread pmaconi at gmail dot com
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 
#include 
#include 
#include 
using namespace std;
void showVector(vector &v);

int main()
{
vector v(100);



for(int i=0; i  &v)

{

//--

// Display elements of a vector, 10 per line

//--

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



[Bug c++/36178] rand() combined with vectors negates setw()

2008-05-07 Thread pmaconi at gmail dot com


--- Comment #1 from pmaconi at gmail dot com  2008-05-08 03:29 ---
Created an attachment (id=15615)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15615&action=view)
Output file from --save-temps


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36178



[Bug c++/36178] rand() combined with vectors negates setw()

2008-05-07 Thread pmaconi at gmail dot com


--- Comment #2 from pmaconi at gmail dot com  2008-05-08 03:29 ---
Created an attachment (id=15616)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15616&action=view)
Output file from --save-temps (.s)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36178



[Bug c++/36178] rand() combined with vectors negates setw()

2008-05-07 Thread pmaconi at gmail dot com


--- Comment #3 from pmaconi at gmail dot com  2008-05-08 03:30 ---
Created an attachment (id=15617)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15617&action=view)
Test .cpp file


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36178



[Bug c++/36178] rand() combined with vectors negates setw()

2008-05-07 Thread pmaconi at gmail dot com


--- Comment #5 from pmaconi at gmail dot com  2008-05-08 05:58 ---
Sorry. When I ran that code from visual studio, rand() always returned no more
than 5 digits. I didn't realize that RAND_MAX was different between the
compilers. 


-- 

pmaconi at gmail dot com changed:

   What|Removed |Added

 Status|WAITING |RESOLVED
 Resolution||INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36178