Forum Discussion
Hello,
You received this warning because of the if loop in your function, it doesn't check for other conditions.
When I tried below code, the warning is not generated:
function example_func (
constant dummy_arg : in integer)
return integer is
begin
if (true) then
return 0;
else
return 1;
end if;
end example_func;
Regards,
Nurina
- roeekalinsky2 years ago
Contributor
Nurina,
Yes, exactly, Quartus is issuing the warning because of the if conditional... but I think you might have missed the point, that Quartus is wrong to use that as its criteria to conclude that the function may not always return a value.
The else branch that you added to appease Quartus is a dead conditional branch that can never be reached, and the 'return 1' that you put there will never execute. The 'if (true) then' branch with its 'return 0' will execute always. The else branch is superfluous. The function in its original form does return a value, the value 0, always.
The fact that Quartus complains in the absence of an else branch containing a return statement, despite the fact that this else branch would be functionally irrelevant and could never be reached anyhow, is exactly what I was trying to demonstrate with the trivial example I provided.
-Roee