git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] remove NORETURN from function pointers

From
Erik Faye-Lund <kusmabite@googlemail.com>
Date
Sep 14, 2009, 13:12 UTC
Message-ID
<40aa078e0909140612w71ad3bdeyfa94838cb57cec19@mail.gmail.com>
In-Reply-To
<4AAE4087.5030607@viscovery.net>
On Mon, Sep 14, 2009 at 3:09 PM, Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 22 quoted lines
> Erik Faye-Lund schrieb:
>> Compiling the following code gives a warning about unreachable code,
>> so it's clear that msvc doesn't simply ignore the directive. I'm not
>> saying that anyone suggested otherwise, I just wanted to know for
>> sure.
>>
>> #include <stdio.h>
>> #include <stdlib.h>
>> void (*exit_fun)(int) = exit;
>> void __declspec(noreturn) die(void);
>> void die(void) { exit_fun(1); }
>> int main(void) { printf("hello!\n"); die(); printf("world!\n"); }
>
> In order to countermand any clever optimizations you should make it
>
> -void (*exit_fun)(int) = exit;
> +extern void (*exit_fun)(int);
>
> (of course, this fails to link). But if this results in only *one* warning
> (that the printf() call is unreachable), then I wouldn't bother with this
> problem anymore, because you really should also have been warned that a
> __declspec(noreturn) function actually does return.
Ah, good point. Still gives the warning (as well as the linker-error), though.
-- 
Erik "kusma" Faye-Lund
kusmabite@gmail.com
(+47) 986 59 656
Previous: Johannes SixtNext: Johannes Sixt
Message 11 of 17 in “remove NORETURN from function pointers”
  1. 2/2 remove NORETURN from function pointersErik Faye-Lund, Sep 14, 2009
  2. Jeff KingSep 14, 2009
  3. Erik Faye-LundSep 14, 2009
  4. Erik Faye-LundSep 14, 2009
  5. Jeff KingSep 14, 2009
  6. Jeff KingSep 14, 2009
  7. Erik Faye-LundSep 14, 2009
  8. Jeff KingSep 14, 2009
  9. Erik Faye-LundSep 14, 2009
  10. Johannes SixtSep 14, 2009
  11. Erik Faye-LundSep 14, 2009
  12. Johannes SixtSep 14, 2009
  13. Erik Faye-LundSep 14, 2009
  14. Johannes SixtSep 14, 2009
  15. Junio C HamanoSep 22, 2009
  16. Erik Faye-LundSep 25, 2009
  17. Erik Faye-LundSep 30, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.