Add defaults to compare_exchange, small fix in printf. Disallow obviously wrong code that returns the pointer to a variable on the stack.

This commit is contained in:
Christoffer Lerno
2023-02-18 12:19:32 +01:00
parent 3da9008fdc
commit ea163636d3
6 changed files with 121 additions and 4 deletions

View File

@@ -0,0 +1,40 @@
fn int[] test1()
{
int[3] x;
return &x; // #error: local variable will be invalid
}
fn int* test2()
{
int[3] x;
return &x[0]; // #error: local variable will be invalid
}
struct Abc
{
int a;
int[3] b;
}
fn int* test3()
{
Abc x;
return &x.a; // #error: local variable will be invalid
}
fn int* test4()
{
Abc x;
return &x.b; // #error: local variable will be invalid
}
fn int* test5()
{
Abc x;
return &x.b[0]; // #error: local variable will be invalid
}
fn int* test6()
{
return &&1; // #error: temporary value will
}