Can 'noreturn' functions throw exceptions?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



QUESTION: May a function marked with the
'noreturn' attribute terminate by throwing
an exception?  The gcc info entry is silent on this
point.

The answer is not obvious, because the spec says the
compiler can avoid generating code needed only if the
function returns (such as saving registers not
preserved by the function).  For an exception to
be caught, it is necessary for the stack-unwinding
library to find active catch blocks in the call chain.
If the compiler did not genrerate the info needed to
walk the call chain, then 'throw' would not work
correctly.

I want to use 'noreturn' for an error function called
from performance-critical inlined code (this
eliminates
register-save instructions in the normal-case flow).

However, the error function throws an excepition which
must be caught at a higher level.  It works in a 
trivial test case on i386/linux.

My question is : Does GCC guarantee that this works
on all platforms?

__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux