Re: Declaring a method as 'noreturn'


 



On Aug 12, 2020, at 4:56 PM, Carl Hoefs <newslists@...> wrote:

- (void)providerCV06 __attribute((noreturn));

Are you sure `noreturn` is appropriate there? I mean, the name "providerCV06" kind of sounds like it actually does something. A `noreturn` function literally never returns, i.e. it either throws an exception or kills the process … is that what you intend?

This is significant because the compiler can and does optimize around this — it can omit a jump after a call to a `noreturn` function because it knows it'll never be reached. If a function marked `noreturn` actually does return, it can cause incorrect behavior.

—Jens

Join xcode@apple-dev.groups.io to automatically receive all group messages.