public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "gabravier at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/107840] New: ICE when compiling cursed setjmp/longjmp that uses __builtin_call_with_static_chain Date: Wed, 23 Nov 2022 16:44:10 +0000 [thread overview] Message-ID: <bug-107840-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107840 Bug ID: 107840 Summary: ICE when compiling cursed setjmp/longjmp that uses __builtin_call_with_static_chain Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: gabravier at gmail dot com Target Milestone: --- typedef __UINT16_TYPE__ uint16_t; typedef __UINT32_TYPE__ uint32_t; typedef __INTPTR_TYPE__ intptr_t; #define unreachable __builtin_unreachable typedef struct{ const uint16_t mov1; const uint32_t addr; const uint16_t mov2; const void * const chain; } __attribute__((packed)) thunk_struct; #define NESTED_CHAIN(p) ({ \ thunk_struct *__t = (void*)p; \ __t->chain; \ }) #define NESTED_ADDR(p) ({ \ auto __p = (p); \ thunk_struct *__t = (void*)__p; \ (typeof(__p))(intptr_t)__t->addr; \ }) #define NESTED_UPGRADE(self, ptr, args) ({ \ if(self != ptr) \ __builtin_call_with_static_chain( \ NESTED_ADDR((typeof(self)*)ptr) args, \ NESTED_CHAIN(ptr) \ ); \ }) typedef struct{ // can't apply standard [[noreturn]] to function pointers [[gnu::noreturn]] void(*fun)(void*, int); }xjmp_buf[1]; #define xsetjmp(env) ({ \ __label__ trgt; \ int __xsetjmp_ret = 0; \ [[noreturn]] void __jmp(void *self, int r){ \ NESTED_UPGRADE(__jmp, self, (self, r)); \ __xsetjmp_ret = r ?: 1; \ goto trgt; \ } \ env[0].fun = __jmp; \ trgt:; \ int tmp = __xsetjmp_ret; \ __xsetjmp_ret = 0; \ tmp; \ }) [[noreturn, gnu::always_inline]] inline void xlongjmp(xjmp_buf env, int r){ ((void(*)(void*, int))NESTED_ADDR(env[0].fun))(env[0].fun, r); unreachable(); } int main(){ int a = 0; xjmp_buf test; void foo(xjmp_buf ctx){ if(!xsetjmp(ctx)){ (volatile void)0; } } foo(test); xlongjmp(test, ++a); } Compiling this code with `-std=c2x` results in the following error: <source>: In function 'foo': <source>:60:14: error: label '({anonymous})' has incorrect context in bb 4 60 | void foo(xjmp_buf ctx){ | ^~~ during GIMPLE pass: cfg dump file: /app/output.c.015t.cfg <source>:60:14: internal compiler error: verify_flow_info failed 0x2008dee internal_error(char const*, ...) ???:0 0xaf90d7 verify_flow_info() ???:0 0x10447c7 cleanup_tree_cfg(unsigned int) ???:0 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Compiler returned: 1 (PS: I cannot seem to get more of the necessary information from Godbolt, although the bug seems simple enough to reproduce without it. Still, this link to the setup I got the bug in might help: https://godbolt.org/z/cd7f4Mdzd)
next reply other threads:[~2022-11-23 16:44 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-23 16:44 gabravier at gmail dot com [this message] 2022-11-23 16:59 ` [Bug middle-end/107840] ICE when compiling cursed setjmp/longjmp nested function calls and non-local jumps pinskia at gcc dot gnu.org 2022-11-23 17:08 ` pinskia at gcc dot gnu.org 2022-11-23 17:09 ` pinskia at gcc dot gnu.org 2022-11-24 14:31 ` marxin at gcc dot gnu.org 2023-02-12 21:08 ` pinskia at gcc dot gnu.org 2023-02-12 21:09 ` pinskia at gcc dot gnu.org 2024-01-09 3:27 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-107840-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).