Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated insight for jmp_buf global variable declarations. #543

Closed
loonatick-src opened this issue Jun 21, 2023 · 1 comment
Closed

Generated insight for jmp_buf global variable declarations. #543

loonatick-src opened this issue Jun 21, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@loonatick-src
Copy link

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;
}
@andreasfertig
Copy link
Owner

Hello @loonatick-src,

thanks for reporting this nice issue. I (re)learned something today :-) std::jmp_buf is roughly defined as:

typedef int jmp_buf[30];

This makes the type behind it an array, but the type does not appear as such. The C++ Insights code did not consider that and was looking for [ to insert the variable name.

A fix will be on its way soon.

Andreas

@andreasfertig andreasfertig added the bug Something isn't working label Jun 21, 2023
andreasfertig added a commit that referenced this issue Jun 21, 2023
Fixed #543: Include variable name of an array with a typdef or using.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants