diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-03-14 15:03:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-14 15:03:08 +0000 |
commit | 2dfc19647774cb26a0f735bda8006068a40cfba0 (patch) | |
tree | 0feabb302e2ce7cc2652b235a1e498788df57f6e /gcc | |
parent | 41f402f0b19c7e4f19f8d4d65d15223d2752f302 (diff) | |
parent | 7d7bc2ce3898294d67761ab176c2c229089fc13b (diff) | |
download | gcc-2dfc19647774cb26a0f735bda8006068a40cfba0.zip gcc-2dfc19647774cb26a0f735bda8006068a40cfba0.tar.gz gcc-2dfc19647774cb26a0f735bda8006068a40cfba0.tar.bz2 |
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>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/backend/rust-compile-intrinsic.cc | 4 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/issue-1024.rs | 11 |
2 files changed, 11 insertions, 4 deletions
diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc index 3665f5d..5fde694 100644 --- a/gcc/rust/backend/rust-compile-intrinsic.cc +++ b/gcc/rust/backend/rust-compile-intrinsic.cc @@ -304,8 +304,6 @@ offset_intrinsic_handler (Context *ctx, TyTy::BaseType *fntype_tyty) gcc_assert (TREE_CODE (bind_tree) == BIND_EXPR); DECL_SAVED_TREE (fndecl) = bind_tree; - - ctx->pop_fn (); ctx->push_function (fndecl); return fndecl; @@ -393,8 +391,6 @@ sizeof_intrinsic_handler (Context *ctx, TyTy::BaseType *fntype_tyty) gcc_assert (TREE_CODE (bind_tree) == BIND_EXPR); DECL_SAVED_TREE (fndecl) = bind_tree; - - ctx->pop_fn (); ctx->push_function (fndecl); return fndecl; diff --git a/gcc/testsuite/rust/compile/torture/issue-1024.rs b/gcc/testsuite/rust/compile/torture/issue-1024.rs new file mode 100644 index 0000000..1095409 --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/issue-1024.rs @@ -0,0 +1,11 @@ +extern "rust-intrinsic" { + pub fn size_of<T>() -> usize; +} + +fn test() -> usize { + unsafe { size_of::<i32>() } +} + +fn main() { + let _a = test(); +} |