visual studio 7.1.6030, bugged? std::random_shuffle or std::vector



You guys see anything wrong with the code here? before I raise a
hub-bub about visual studio 2003 being broken?

Tried to make the most simplistic test case as possible.

Here is test code to prove the case. It appears to only be bugged when
using vector<bool> as a container. We tested over several iterations
with bools, ints and floats, and everything works as expected except
for vector<bool>. This was compiled on version 7.1.3088 and 7.1.6030 of
Visual Studio 2003. I remember when I was new to programming how people
would always claim the compiler was broken only to find out it was a
silly code mistake and I hope this is not one of those times, but it
sure seems to be broken.

#include <algorithm>
#include <vector>
#include <iostream>
#include <ctime>

using namespace std;

int main()
{
vector<bool> mvector;
int count = 1;

mvector.resize(4);
srand(time(NULL));

for(int i = 0; i < 4; i++)
mvector[i] = i < count;

cout << "Before\n";
cout << "vector size: " << mvector.size() << endl;

for(vector<bool>::iterator i = mvector.begin(); i != mvector.end();
i++)
cout << *i << endl;

random_shuffle( mvector.begin(), mvector.end() );

//DEBUG
cout << "\n\nAfter\n";
cout << "vector size: " << mvector.size() <<std::endl;

for(vector<bool>::iterator i = mvector.begin(); i != mvector.end();
i++)
cout << *i << endl;

system("pause");
return 0;
}



Output:
Before
vector size: 4
1
0
0
0

After
vector size: 4
1
1
1
1

.



Relevant Pages

  • Re: History of - if(p) delete p; - ... ?
    ... As things are the following works just fine under Visual Studio: ... the time: int* p = ... ... pointer, the compiler will have to. ...
    (microsoft.public.vc.language)
  • Re: data types
    ... Usually short is smaller than an int. ... Your compiler is either *really* old or broken or both. ... recommend either a version of gcc,, or Visual Studio ... Microsoft's Visual Studio Express has an onerous EULA). ...
    (comp.lang.c)
  • Re: As the Crow flies.
    ... unsigned long int count_primes{ ... // Uses S. of E. algo to return the number of primes p < x. ... I don't know how to turn that on in Visual Studio. ... my compiler uses 'unsigned long long' or 'unsigned ...
    (talk.origins)
  • Re: As the Crow flies.
    ... unsigned long int count_primes{ ... // Uses S. of E. algo to return the number of primes p < x. ... What compiler are you using? ... I don't know how to turn that on in Visual Studio. ...
    (talk.origins)
  • Re: Create vj# dll
    ... Open Visual Studio. ... public class Class1 implements ITest ... public void set_Value(int number) ... Open Tools + Ole/COM Object Viewer in Visual Studio. ...
    (microsoft.public.dotnet.vjsharp)