FW: noreturn atribute and its optimization

boris smidt borissmidt@hotmail.com
Wed Nov 4 20:51:00 GMT 2015





The noreturn attribute is an indication to the caller that the callee  does not return, and thus it can optimize the caller accordingly, and avoid warnings about missing return values in the caller. It does not direct the compiler to optimize the callee, and even if it  did, with optimizations disabled, it wouldn't. 


But the callee also knows that it will not return so why isn't it optimized. Especially when it is C and no long jump is are used then couldn't it safely reset the stack?
Since it knows it will never use any variables declared on the stack before its call was made. (except maybe with pointers to its own stack...)

Also i even had -O3 to generate the assembly of the noreturn code in mine post which was actually worse than the same code without attributes.  The callee nor the caller where optimized.



     


More information about the Gcc-help mailing list