Skip to content

Commit acdf404

Browse files
committed
allow local variable address detection to regress
See #3180 for a more comprehensive plan to catch this problem. More sophisticated control flow analysis is needed to provide compile errors for returning local variable addresses from a function.
1 parent 5ea79bf commit acdf404

File tree

1 file changed

+0
-19
lines changed

1 file changed

+0
-19
lines changed

test/compile_errors.zig

-19
Original file line numberDiff line numberDiff line change
@@ -5292,25 +5292,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
52925292
"tmp.zig:2:30: error: cannot set section of local variable 'foo'",
52935293
});
52945294

5295-
cases.add("returning address of local variable - simple",
5296-
\\export fn foo() *i32 {
5297-
\\ var a: i32 = undefined;
5298-
\\ return &a;
5299-
\\}
5300-
, &[_][]const u8{
5301-
"tmp.zig:3:13: error: function returns address of local variable",
5302-
});
5303-
5304-
cases.add("returning address of local variable - phi",
5305-
\\export fn foo(c: bool) *i32 {
5306-
\\ var a: i32 = undefined;
5307-
\\ var b: i32 = undefined;
5308-
\\ return if (c) &a else &b;
5309-
\\}
5310-
, &[_][]const u8{
5311-
"tmp.zig:4:12: error: function returns address of local variable",
5312-
});
5313-
53145295
cases.add("inner struct member shadowing outer struct member",
53155296
\\fn A() type {
53165297
\\ return struct {

0 commit comments

Comments
 (0)