Closed souragc closed 10 months ago
This code uses statement expressions, which is a GCC extension to C. This was never an officially supported C extension for Checked C, although the compiler does attempt to compile the code. The compiler support is only partly done and not well-tested.
A statement expression is an expression that wraps a compound block. The specific bug is at line 499 in CanonBounds.cpp, which is doing lexicographic comparison of expressions. The code assumes that the children of all expressions in the AST are also expressions. For statement expressions, this assumption is violated. The child node of a statement expression is a statement.
We can improve he support more so to avoid this crash. Statement expressions should not be appearing in bounds expression, so we should not even be reaching the code doing a lexicographic comparison. The likely fix is to mark all statement expressions as modifying expressions, even though this particular example isn't a modifying expression. We likely should look at what kinds of bounds are being inferred for statement expressions also.
Code:
Command to reproduce