# (move) control may reach end of non-void function

Please go easy on me :( I feel like I'm over-complicating things.

``````bool move(int tile)
{
// TODO
int h;
int k;
for (int i = 0; i < d; i++)
{
for (int j = 0; j < d; j++)
{
if (board[i][j] == tile)
{
h = i;
k = j;
}
}
}

int a = 0;
int b = 0;
if (moving(h, k, a, b))
{
int temp = board[h][k];
board[h][k] = board[a][b];
board[a][b] = temp;
}
else
{
return false;
}
}

bool moving(int h, int k, int a, int b)
{
//check up down left right
if (board[h + 1][k] == 0)
{
a = h + 1;
b = k;
return true;
}
if (board[h - 1][k] == 0)
{
a = h - 1;
b = k;
return true;
}
if (board[h][k + 1] == 0)
{
a = h;
b = k + 1;
return true;
}
if (board[h][k - 1] == 0)
{
a = h;
b = k - 1;
return true;
}
else
{
return false;
}
}
``````

control may reach end of non-void function

It says right there that it'll return true or false in that if else statement but it thinks it's going to run forever.

• Where does it say `return true;` in the `move` function (which is a non-void function) ? – DinoCoderSaurus Feb 23 '17 at 13:51