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

static analysis error (merging states) #223

Open
thradams opened this issue Jan 2, 2025 · 1 comment
Open

static analysis error (merging states) #223

thradams opened this issue Jan 2, 2025 · 1 comment

Comments

@thradams
Copy link
Owner

thradams commented Jan 2, 2025

http://thradams.com/cake/playground.html?code=CiNwcmFnbWEgc2FmZXR5IGVuYWJsZQoKdm9pZCogX093bmVyIF9PcHQgY2FsbG9jKGludCBuICwgdW5zaWduZWQgbG9uZyBzaXplKTsKdm9pZCBmcmVlKHZvaWQqIF9Pd25lciBfT3B0IHB0cik7CgpzdHJ1Y3QgWAp7CiAgICBpbnQgKiBfT3duZXIgX09wdCBkYXRhOwp9OwoKdm9pZCB4X2RlbGV0ZShzdHJ1Y3QgWCAqIF9Pd25lciBfT3B0IHApCnsKICAgIGlmIChwKSB7CiAgICAgICAgZnJlZShwLT5kYXRhKTsKICAgICAgICBmcmVlKHApOwogICAgfQp9CgpzdHJ1Y3QgWCAqX09wdCBfT3duZXIgZihpbnQgYykgewogICBzdHJ1Y3QgWCogX093bmVyIF9PcHQgcCA9IGNhbGxvYygxLCBzaXplb2YgKiBwKTsKICAgdHJ5CiAgIHsKICAgICAgIGlmIChjKSB0aHJvdzsgCiAgIH0gCiAgIGNhdGNoCiAgIHsKICAgICB4X2RlbGV0ZShwKTsKICAgICBwID0gMDsgICAgIAogICB9CiAgIHN0YXRpY19kZWJ1ZygqcCk7CiAgIHJldHVybiBwOwp9Cgo%3D&to=-2&options=

#pragma safety enable

void* _Owner _Opt calloc(int n , unsigned long size);
void free(void* _Owner _Opt ptr);

struct X
{
    int * _Owner _Opt data;
};

void x_delete(struct X * _Owner _Opt p)
{
    if (p) {
        free(p->data);
        free(p);
    }
}

struct X *_Opt _Owner f(int c) {
   struct X* _Owner _Opt p = calloc(1, sizeof * p);
   try
   {
       if (c) throw; 
   } 
   catch
   {
     x_delete(p);
     p = 0;     
   }
   static_debug(*p);
   return p;
}
@thradams
Copy link
Owner Author

thradams commented Jan 2, 2025

Smaller sample

#pragma safety enable

void* _Owner _Opt calloc(int n , unsigned long size);
void free(void* _Owner _Opt ptr);

struct X {
    int i;
};

void x_delete(struct X * _Owner _Opt p);

struct X *_Opt _Owner f(int c)
{
   struct X* _Owner _Opt p = calloc(1, sizeof * p);
   try   {
       if (c) throw; 
   } 
   catch {
     x_delete(p);
     p = 0;     
   }   
   return p;
}

@thradams thradams changed the title static analysis error static analysis error (merging states) Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant