Hi Tomsy and Lydia --
I agree that someone should open a GitHub issue against this. Note that
if halt() is used instead of exit(), the compiler does not issue a similar
warning, suggesting that we already have logic that can handle such cases,
but that it just doesn't cover exit() for some reason... So it may also
have a five-minute fix (in which case no issue would need to be opened).
-Brad
On Fri, 2 Jun 2017, Lydia Duncan wrote:
Hi!
Without further context, I can't be certain, but I suspect that your inline
proc has a path through itself with the exit() branch where no return
statement is present, i.e.
inline proc exiter(x: int): int {
if (x > 10) {
exit(0);
} else {
return x;
}
}
I verified locally that an inline proc can use exit() when the function
either:
a) doesn't expect to return anything or
b) has a return statement that is reachable, even through a branch with
exit() in it.
So you could insert a bogus return statement after the exit() to get around
this issue.
It seems potentially inappropriate to me that exit() is not recognized as
okay when ensuring that a function will always return. Do others agree?
Would you like to open an issue on that? Or shall I do it for you?
Thanks,
Lydia
On 06/02/2017 01:37 AM, Tomsy Paul wrote:
Dear all,
I was trying to exit from an inline proc using exit(). My intention was to
exit from the entire program (similar to exit() in C). I get the error
"error: control reaches end of function that returns a value"
Can some one explain it.
How can I exit from such a function?
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers