]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: parser: Fix ICE in AnonConst by handling null macro result
authorjayant chauhan <0001jayant@gmail.com>
Sun, 1 Feb 2026 13:18:28 +0000 (18:48 +0530)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 27 Feb 2026 14:57:10 +0000 (15:57 +0100)
commit91c0dff5482d716cfd11729668dfeea9ae784dbb
tree8da0d9b233e505be7bd7e61c9e5b960bd88cbbb3
parente778339f5bab3b1c13ff44a7f8b4c301ae52d423
gccrs: parser: Fix ICE in AnonConst by handling null macro result

The parse_anon_const function triggered an assertion failure (ICE) when
receiving a success Result containing a null expression pointer. This
occurred because null_denotation_path directly returned the result of
parse_macro_invocation_partial (which returns a raw pointer) without
checking for failure.

When parse_macro_invocation_partial failed (returning nullptr), it was
wrapped into a tl::expected success state containing nullptr, rather than
an error state.

This patch adds a check in null_denotation_path to verify if the parsed
macro invocation is null. If it is, it now returns a tl::unexpected error,
ensuring that invalid expressions are correctly reported as errors
upstream.

Fixes Rust-GCC#4412

gcc/rust/ChangeLog:

* parse/rust-parse-impl-expr.hxx (null_denotation_path): Check
if macro invocation returns null and return error.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
gcc/rust/parse/rust-parse-impl-expr.hxx
gcc/testsuite/rust/compile/issue-4412.rs [new file with mode: 0644]