with Text_io; use Text_io; procedure test1 is type Root (K : boolean) is tagged null record;
type Root_Access is access Root'Class; type Child is new Root (K => True) with null record; Var : Root_Access; begin begin Var := new Child'(K => False); put_line("FAILED " & Boolean'Image(Var.K)); exception when Constraint_Error => Put_line("PASSED"); end; end; Per ARM 3.7(26), type Root is unconstrained because it has a known_discriminant_part. Per 3.4(6), Child is unconstrained because its parent is unconstrained. However, its parent_subtype_indication does specify a constraint. The allocator "new Child'(K => False)" uses a qualified_expression that violates this constraint; therefore its evaluation should raise Constraint_Error at run time, per 4.7(4). The program should print PASSED but instead prints "FAILED FALSE". As a quality of implementation issue, it would be nice if GNAT would warn at compile time of this constraint violation. -- Summary: Program fails to raise Constraint_Error as mandated by ARM 4.7(4) Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ludovic at ludovic-brenta dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38332