Suppose I have a function with signature [[noreturn]] void die(int exit_code);. If I write the statement:
check_some_condition() or die(EXIT_FAILURE);
I get an error message (with GCC 5.4.0):
error: expression must have bool type (or be convertible to bool)
but why is the type checked, if the compiler knows that going into that function, the return value won't matter; and if the condition checks out, again the return type doesn't matter?
Edit: Does the wording of the standard regarding [[noreturn]] not address this point, i.e. relax the requirements regarding types so as to "legitimize" such expressions?
Every expression must have a well determined type, period. So even though the function doesn't return, it must still be possible to evaluate the type of the expression
check_some_condition() or die(EXIT_FAILURE)And from that it follows that the function return type must be viable for use in a logical operation.