Skip to content

gccrs: constructors that get borrowed need to be addressable - #4877

Merged
philberty merged 1 commit into
masterfrom
phil/constexpr
Sep 10, 2026
Merged

gccrs: constructors that get borrowed need to be addressable#4877
philberty merged 1 commit into
masterfrom
phil/constexpr

Conversation

@philberty

Copy link
Copy Markdown
Member

When we have const expr dealing with slices we end up taking a pointer of an array as the data pointer. This is a cosntructor expr ususally but const eval expects these to be addressable objects like tmps holding onto the data but we get away with this in regular compilation because gcc optimizes it.

Fixes #4867
Fixes #4868

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::visit): make addressable
* backend/rust-constexpr.cc (eval_store_expression): port over missing cp/constexpr.cc

gcc/testsuite/ChangeLog:

* rust/compile/issue-4867.rs: New test.

When we have const expr dealing with slices we end up taking a pointer of
an array as the data pointer. This is a cosntructor expr ususally but const
eval expects these to be addressable objects like tmps holding onto the data
but we get away with this in regular compilation because gcc optimizes it.

Fixes #4867
Fixes #4868

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit): make addressable
	* backend/rust-constexpr.cc (eval_store_expression): port over missing cp/constexpr.cc

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4867.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
@philberty philberty added the core Issue related to the compilation of the `core` crate label Sep 10, 2026
@philberty
philberty added this pull request to the merge queue Sep 10, 2026
Merged via the queue into master with commit 1a69267 Sep 10, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issue related to the compilation of the `core` crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE in const eval mismatched types fnptr

1 participant