const int IX(int x, int y, std::size_t width)
{
if ((width * y + x) > 0)
{
return width * y + x;
}
else
{
return 0;
}
}
const int IX(int x, int y, std::size_t width)
{
int value = width * y + x;
if (value > 0)
{
return value;
}
else
{
return 0;
}
}
In here if x=0
and y=-1
independent of width
the first function returns the first branch (why?), and the second one returns what is expected. Is this a compiler bug, or am i missing something?
Im using visual studio 2019 compiler.