certain compiler, derived from EDG gives me expression has no effect
warning
on this line
return 1 << ((i == j) + (k == l) + ((i == k) & (j == l)));
values are runtime values, compiler does not know them.
return 1 << (((i == k) & (j == l))); // no warning here
return 1 << ((i == j) + (k == l)); //or here
am I missing something or is compiler confused?
the code segment below does not have warning. if a change parameters to constant reference, warning come back
//static int symmetry(const int &i, const int &j, const int &k, const int &l) {
static int symmetry(int i, int j, int k, int l) {
// return 1 << ((i == j) + (k == l));
//return 1 << (((i == k) && (j == l)) + (k != l));
return 1 << ((i == j) + (k == l) + ((i == k) && (j == l)));
}
the program is correct even with warning. possibility that program is wrong is very very small this particular code segment would throw calculations off
thank you for your time, I am going to assume compiler is making mistake here. just in case you find similar problem, compiler is nvcc, NVIDIA gpu cuda compiler