Bug related to std::vector

Hi,
the simple program below produces a segmentation violation when executed in CINT (CINT/ROOT C/C++ Interpreter version 5.16.16, November 24, 2006), but runs without problem when compiled.
The strange thing is that if I replace the loop in which change() is called by only a call to this function - so practically the same program - everything works, also in CINT.
Searching in the forum I have seen a few bug reports concerning std::vector, so probably the only solution at the moment is using the compiled program?
Tonio

#include <vector> #include <iostream> using namespace std; void change(vector<int>& vec) { vec[0]=1; } void test() { vector<int> trace(10); for (int i=0; i<trace.size(); i++) trace[i]=i; for (int j=0; j<1; j++) change(trace); } int main() { test(); }

Hi again,
in another thread (“long long problem”) I found a work-around:
Disabling the bytecode generator by executing ‘.O 0’ in CINT helps also in my case.
So it seems the problem is not (only) the usage of the vector reference, but that bytecode compiler seems to have problems with for loops in connection with certain types!?

Hi Tonio,

I had a look at your problem and yes, it is caused by the byte-code optimizer. So .O0 is in fact a work-around.

Axel.