Commit 9ed1331
parser: Fix ICE on invalid arithmetic expression
The compiler previously crashed with a segmentation fault when parsing
an arithmetic expression where the left-hand side was invalid (e.g.,
after a failed macro expansion). This occurred because the parser
attempted to access the location of the null 'left' pointer. This
patch adds a check to ensure the left operand is valid before proceeding.
Fixes #4414
gcc/rust/ChangeLog:
* parse/rust-parse-impl-expr.hxx (parse_arithmetic_or_logical_expr):
Check for null left operand to prevent segmentation fault.
gcc/testsuite/ChangeLog:
* rust/compile/issue-4414.rs: New test.
Signed-off-by: Harishankar <harishankarpp7@gmail.com>1 parent 4c81795 commit 9ed1331
File tree
2 files changed
+33
-1
lines changed- gcc
- rust/parse
- testsuite/rust/compile
2 files changed
+33
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1794 | 1794 | | |
1795 | 1795 | | |
1796 | 1796 | | |
1797 | | - | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
1798 | 1800 | | |
1799 | 1801 | | |
1800 | 1802 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
0 commit comments