Skip to content

Commit 2dfc196

Browse files
bors[bot]philberty
andauthored
Merge #1025
1025: Fix memory corruption in generation of builtin functions r=philberty a=philberty This patch removes the pop_fn calls since no fncontext stack is required here for these intrinsic. More context on the issues is in the commit message. Fixes #1024 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2 parents 41f402f + 7d7bc2c commit 2dfc196

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

gcc/rust/backend/rust-compile-intrinsic.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,6 @@ offset_intrinsic_handler (Context *ctx, TyTy::BaseType *fntype_tyty)
304304

305305
gcc_assert (TREE_CODE (bind_tree) == BIND_EXPR);
306306
DECL_SAVED_TREE (fndecl) = bind_tree;
307-
308-
ctx->pop_fn ();
309307
ctx->push_function (fndecl);
310308

311309
return fndecl;
@@ -393,8 +391,6 @@ sizeof_intrinsic_handler (Context *ctx, TyTy::BaseType *fntype_tyty)
393391

394392
gcc_assert (TREE_CODE (bind_tree) == BIND_EXPR);
395393
DECL_SAVED_TREE (fndecl) = bind_tree;
396-
397-
ctx->pop_fn ();
398394
ctx->push_function (fndecl);
399395

400396
return fndecl;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
extern "rust-intrinsic" {
2+
pub fn size_of<T>() -> usize;
3+
}
4+
5+
fn test() -> usize {
6+
unsafe { size_of::<i32>() }
7+
}
8+
9+
fn main() {
10+
let _a = test();
11+
}

0 commit comments

Comments
 (0)