On Mon, 2024-10-07 at 14:25 +0200, Jakub Jelinek wrote: > On Mon, Oct 07, 2024 at 03:05:56PM +0300, Дилян Палаузов wrote: > > does [[noreturn]] optimize the generated [[noreturn]] function itself, or > > it optimizes the calls to the [[noreturn]] function? Hence, in the latter > > case optimizations are done based on function declaration, irrespective of > > function body. > > Of course the latter, that is the whole point of the attribute. > In the definition of [[noreturn]] function itself, all it can do is > warn if the function does return anyway.
Technically it also turns the return statements in the function body into __builtin_unreachable(), if we call this an "optimization." In C++ it's done for non-void function even without [[noreturn]] as allowed by the C++ standard. -- Xi Ruoyao <xry...@xry111.site> School of Aerospace Science and Technology, Xidian University