As far as I understand, C++ attribute [[noreturn]]
can be applied to functions not returning to the caller so that the compiler can generate more optimised code. I do understand it makes a difference for "normal" functions, but was wondering if it also makes a difference in performance when applying it to the main
function.
Assuming I want to write a program constantly running with no chance it aborts (meaning the main
function will never return to the caller (= operating system)
Which of this generates in faster (more optimised) code or does it not make a difference at all?
Option 1:
int main()
{
while(true)
//..
return 0;
}
Option 2:
[[noreturn]] int main()
{
while(true)
//..
return 0;
}