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

Missing warning when calling a function with moved pointer #228

Open
thradams opened this issue Jan 19, 2025 · 0 comments
Open

Missing warning when calling a function with moved pointer #228

thradams opened this issue Jan 19, 2025 · 0 comments

Comments

@thradams
Copy link
Owner

#pragma safety enable

void* _Owner _Opt malloc(unsigned long size);
void free(void* _Owner _Opt ptr);

int main() {
   void * _Owner _Opt p = malloc(1);
   void *_Owner _Opt p2 = p;    //MOVED
   free(p2);   
   free(p); //MOVED
}

http://thradams.com/cake/playground.html?code=I3ByYWdtYSBzYWZldHkgZW5hYmxlDQoNCnZvaWQqIF9Pd25lciBfT3B0IG1hbGxvYyh1bnNpZ25lZCBsb25nIHNpemUpOw0Kdm9pZCBmcmVlKHZvaWQqIF9Pd25lciBfT3B0IHB0cik7DQoNCmludCBtYWluKCkgew0KICAgdm9pZCAqIF9Pd25lciBfT3B0IHAgPSBtYWxsb2MoMSk7DQogICB2b2lkICpfT3duZXIgX09wdCBwMiA9IHA7ICAgDQogICBmcmVlKHAyKTsgICANCiAgIHN0YXRpY19kZWJ1ZyhwKTsNCiAgIGZyZWUocCk7DQp9&to=-2&options=

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