thradams / cake

Cake a C23 front end and transpiler written in C
http://thradams.com/cake/index.html
GNU General Public License v3.0
543 stars 23 forks source link

ownership checks in if with initializer not working #152

Closed thradams closed 2 months ago

thradams commented 7 months ago

it needs to show an warning.

#include <ownership.h>
#include <stdio.h>

int main()
{
   int size = 10;
   if (FILE* owner f = fopen("file.txt", "r"); f)
   {
     /*...*/
     //fclose(f);
   }
}
thradams commented 2 months ago
#pragma safety enable
#include <stdio.h>

int main()
{
   int size = 10;
   if (FILE* _Owner _Opt f = fopen("file.txt", "r"); f)
   {
     /*...*/
     //fclose(f);
   }
}