For an object X of a composite type, the attribute X'Valid_Scalars should return False if and only if there exists at least one invalid scalar subcomponent of X. The validity test for a scalar part may include a range test. In some cases involving a private type that is implemented as a signed integer type, this range test was incorrectly implemented using unsigned comparisons. For an enclosing object X, this could result in X'Valid_Scalars yielding the wrong Boolean result. Such an incorrect result would almost always be False, although an incorrect True result is theoretically possible (this would require that both bounds of the component subtype are negative and that the invalid component has a positive value). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_attr.adb (Make_Range_Test): In determining which subtype's First and Last attributes are to be queried as part of a range test, call Validated_View in order to get a scalar (as opposed to private) subtype. (Attribute_Valid): In determining whether to perform a signed or unsigned comparison for a range test, call Validated_View in order to get a scalar (as opposed to private) type. Also correct a typo which, by itself, is the source of the problem reported for this ticket.