G
Goran Sliskovic
Hi,
I have following piece of code:
#include <iostream>
using namespace std;
void f(int i) {
throw (int)0;
}
int main()
{
int i = 0;
try {
f(i++);
}
catch(int x) {
}
cout << i << endl;
return 0;
}
Using VC7.1 I get 1 as a result in debug mode, 0 in release. I thought this
was defined behaviour as i++ should be evaluated prior to function call and
have all side-effects completed. Am I missing something (exception thrown
makes this undefined?) or is it a bug in the compiler?
Regards,
Goran
I have following piece of code:
#include <iostream>
using namespace std;
void f(int i) {
throw (int)0;
}
int main()
{
int i = 0;
try {
f(i++);
}
catch(int x) {
}
cout << i << endl;
return 0;
}
Using VC7.1 I get 1 as a result in debug mode, 0 in release. I thought this
was defined behaviour as i++ should be evaluated prior to function call and
have all side-effects completed. Am I missing something (exception thrown
makes this undefined?) or is it a bug in the compiler?
Regards,
Goran