NO

Author Topic: Error when executing setjmp with the thread_local variable  (Read 195 times)

Offline Prokrust

  • Member
  • *
  • Posts: 6
Error when executing setjmp with the thread_local variable
« on: January 29, 2021, 01:39:05 pm »
The error occurs when executing the following code:
Code: [Select]
#include <stdio.h>
#include <threads.h>
#include <setjmp.h>

thread_local jmp_buf _zmem_jmp_;
void qaz(void) {
printf("Qaz\n");
longjmp(_zmem_jmp_,1);
}

int main(int argc, char *argv[]) {
printf("Start\n");
if(!!setjmp(_zmem_jmp_)) { printf("End\n"); return 0; }
qaz();
return 0;
}

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2101
    • http://www.smorgasbordet.com
Re: Error when executing setjmp with the thread_local variable
« Reply #1 on: January 29, 2021, 07:34:03 pm »
OK, I havn't done much testing, but it appears to work here...
You need to at least include both the error code/message, and all the compiler options used...
/Pelle

Offline Prokrust

  • Member
  • *
  • Posts: 6
Re: Error when executing setjmp with the thread_local variable
« Reply #2 on: February 09, 2021, 02:09:49 pm »
Checked it. Yes, it works with step-by-step debugging and with a separate run outside the environment. But when running from PellesC, an error occurs for some reason:
CRT: unhandled exception (main) -- terminating
*** Process returned 255 ***
PS.
Added a project
PS.PS.
operating system: Windows 7 SP1
« Last Edit: February 09, 2021, 02:14:27 pm by Prokrust »