A subroutine never returns.
This diagnostic indicates that a subroutine failed to return, either because it always throws an exception or calls longjmp in such a way that control passes out of the subroutine to a routine higher up on the call stack. It is not issued for routines that call library routines like exit, abort, or FORTRAN STOP, although these routines also do not return. It is also not issued for routines that always execute an infinite loop, although infinite loops themselves are reported by a different diagnostic.
While there is nothing wrong with exiting a subroutine in this way, a subroutine that always exits in this way is usually adhering to a bad coding style. The reason this style of code in discouraged is because it creates a false impression to the user. It is clearer if the subroutine returns to the caller and then the caller throws the exception or calls longjmp.
ID |
Observation |
Description |
---|---|---|
1 |
Definition |
Subroutine definition |
#include <stdio.h> void never_returns() { abort(); // this routine never returns ... } int main (int argc, char **argv) { int j; j = 1; never_returns(); printf("%d\n",j); // so this is unreachable code return 0; }
Copyright © 2010, Intel Corporation. All rights reserved.