I'm having problems with a test case that's been simplified from code
that uses the min() template function in the algorithm header:
> sgiCC -O2 min.cpp
> a.out
456048 <-- should be 4
We suspect that the front end is generating incorrect code, which causes
the optimizer to delete stores that it thinks are unnecessary because
they only affect local variables.
#include <iostream>
const int& min(const int& __a, const int& __b) {
return __b < __a ? __b : __a;
}
int j=4, k=7;
void main()
{
int i = min(j,k);
cout << i << endl;
}
|