Skip to content

Conversation

philberty
Copy link
Member

This patch handles the overflowed var expression in the const block, so that we error properly in the const expr code. It was missing some stuff from the c++ implementation in how this should be handled properly.

Fixes #4139

gcc/rust/ChangeLog:

* backend/rust-constexpr.cc (struct constexpr_global_ctx): port over c++ helpers
(decl_really_constant_value): likewise
(eval_constant_expression): likewise
(non_const_var_error): likewise

gcc/testsuite/ChangeLog:

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

Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

This patch handles the overflowed var expression in the const block, so that
we error properly in the const expr code. It was missing some stuff from the
c++ implementation in how this should be handled properly.

Fixes #4139

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::compile_integer_literal): cleanup
	* backend/rust-constexpr.cc (struct constexpr_global_ctx): port over c++ helpers
	(decl_really_constant_value): likewise
	(eval_constant_expression): likewise
	(non_const_var_error): likewise

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
@philberty philberty added this pull request to the merge queue Sep 16, 2025
Merged via the queue into master with commit c3ca1b9 Sep 16, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

segfault contains_struct_check, possibly const overflow
2 participants