I've never seen [[ noreturn ]] used on non-void returning functions before.
Is the following well defined?
[[ noreturn ]] int function();
int function(){
while(true){/* impl */}
return 0;
}
The reason the return type must be int
, is because the function is passed to another function via a function pointer.
So assuming the caller looks something like this:
//call the non-returning function
int var = (*fptr)();
//use var some way (even though the function will never actually return)
std::cout << var;
will this exhibit any kind of undefined behavior?
Aucun commentaire:
Enregistrer un commentaire