Skip to content

Generated insight for jmp_buf global variable declarations. #543

@loonatick-src

Description

@loonatick-src

When including setjmp.h and declaring a global variable with type jmp_buf, the generated insight is just std::jmp_buf = std::jmp_buf.

Example source code (line 3):

#include <cstdio>
#include <csetjmp>
std::jmp_buf jump_buffer;

void foo() {
    printf("foo: Entered\n");
    longjmp(jump_buffer, 1);  // Jump back to where setjmp was called
    printf("foo: This won't be executed\n");
}

int main() {
    if (setjmp(jump_buffer) == 0) {
        printf("main: Calling foo\n");
        foo();
    } else {
        printf("main: Jumped back from foo\n");
    }

    printf("main: Exiting\n");
    return 0;
}

Generated insight (line 3):

#include <cstdio>
#include <csetjmp>
std::jmp_buf = std::jmp_buf();


void foo()
{
  printf("foo: Entered\n");
  longjmp(jump_buffer, 1);
  printf("foo: This won't be executed\n");
}


int main()
{
  if(_setjmp(jump_buffer) == 0) {
    printf("main: Calling foo\n");
    foo();
  } else {
    printf("main: Jumped back from foo\n");
  } 
  
  printf("main: Exiting\n");
  return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions