On 2017-07-08 12:15, Walter Bright wrote:
C compilers (and by extension C++ compilers) usually have an extension
which allows a function to be marked as one that never returns. The
point of this is it enables improved data flow analysis and better code
being generated.
Noreturn functions crop up in things like assert's and enforce's. DMD
internally hardcodes a few functions it knows about that are noreturn,
and the DMD optimizer and codegen take advantage of it.
But when people write their own assert's and enforce's, this falls
apart. While the programs will still work, they won't be as efficient as
they could be.
I'm going to ask the stupid question: I understand that this is for the
compiler to generate better code. But, since the attribute (or whatever
it is) indicates that a function won't return, it can only be used in
very few cases. Are those few cases worth optimizing for?
--
/Jacob Carlborg