GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ada

Fix Ada assertion checking for pathological slice code

Ada compiler assertion failure fixed for code creating array slices from invalid arithmetic operations.

This commit addresses an assertion checking failure in the Ada front-end when encountering pathological code. The issue arose from a specific construct where an array slice was fabricated by interpreting the result of subtracting two integers as an array. A new test case, slice11.adb, is added to cover this scenario.

In Details

This patch fixes PR ada/89786 by adding special handling in gcc-interface/utils.cc's unchecked_convert function. The problematic code involves converting the result of a binary operation (specifically, subtraction) directly to an array type, which would then be used to form a slice. The fix ensures that such invalid conversions do not trigger assertion failures during compilation.

For Context
Ada
A structured, statically typed, imperative, and object-oriented high-level programming language designed for large, long-lived applications where reliability and efficiency are crucial.
Assertion checking
A debugging technique where developers insert checks (assertions) into their code to verify assumptions. If an assertion fails, the program typically halts, indicating a logical error.
Slice
In Ada, a slice refers to a contiguous subsequence of an array.
Pathological code
Code that is syntactically valid but represents an extreme or unusual case, often designed to test the limits or uncover bugs in a compiler or system.
Filed Under: gccadacompiler bugtestsuite