c++ - Why is a [[noreturn]] function checked for return type? -


suppose have function signature [[noreturn]] void die(int exit_code);. if write statement:

check_some_condition() or die(exit_failure); 

i error message (with gcc 5.4.0):

error: expression must have bool type (or convertible bool) 

but why type checked, if compiler knows going function, return value won't matter; , if condition checks out, again return type doesn't matter?

edit: wording of standard regarding [[noreturn]] not address point, i.e. relax requirements regarding types "legitimize" such expressions?

noreturn doesn't tell compiler function returns no value. tells compiler function not return. has no effect on function's return type.

in expression, compiler required check operands of expressions have valid types. in expression check_some_condition() or die(exit_failure), requires return type of both check_some_condition() , die() checked. noreturn not affect function's return type, not affect need check. if function returns void, expression invalid.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -