Ada: Fix crash in can_equal_min_or_max_val_p
Prevents a crash in Ada code generation by ensuring min/max value checks only apply to integral types.
This commit addresses a crash in the Ada compiler’s code generation phase, specifically within the can_equal_min_or_max_val_p function. The function previously attempted to compare minimum or maximum values for pointer types, for which such concepts are undefined. The fix adds a guard to ensure this check is only performed when dealing with known integral types, thus preventing the crash.
In Details
The function can_equal_min_Or_max_val_p in gcc-interface/trans.cc was updated to prevent a crash when processing pointer types. It now includes a guard that checks if the type is an integral type before attempting to update the value based on min/max comparisons. This avoids erroneous operations on pointer types where min/max values are not meaningful, fixing PR127495.
- integral type
- A data type that represents whole numbers, such as integers (
int,long). This is in contrast to floating-point types or pointer types. - pointer type
- A data type that stores the memory address of another variable or function. Examples include
int*,char*. - code generation
- The phase of the compiler where the intermediate representation of the program is translated into machine code or assembly language for a specific target architecture.