Bug 18455 - incorrect execution
Summary: incorrect execution
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 3.4.2
: P2 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2004-11-12 16:39 UTC by Ludovic Brenta
Modified: 2007-05-02 11:32 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-06-14 20:45:44


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludovic Brenta 2004-11-12 16:39:19 UTC
(Debian bug #280940)

-- RM 3.10(15)  "An access value satisfies a composite_constraint
-- of an access subtype if it ... designates an object whose value
-- satisfies the constraint."

with text_io;
procedure Test_131 is
   type string_ptr is access all string;
   subtype str10 is string_Ptr(1..10);
   xstr20: aliased string := (1..20 => 'a');
   xstr10: str10;
begin
   xstr10 := xstr20'Access; -- line 12
   text_io.put_line("FAILED, constraint_error not raised");
exception
   when constraint_error =>
     text_io.put_line("PASSED, constraint_error raised");
end Test_131;


Expected output: the compiler says nothing, the program prints:
PASSED, constraint_error raised

Actual output with gnat 3.15p:

test_131.adb:12:14: object subtype must statically match designated subtype
gnatmake: "test_131.adb" compilation error

which is incorrect.  With gnat-3.4 3.4.2-2, the compiler says nothing
(correct) but the program runs and outputs:

FAILED, constraint_error not raised
Comment 1 Andrew Pinski 2004-11-24 21:13:38 UTC
Confirmed.
Comment 2 Arnaud Charlet 2007-05-02 11:32:46 UTC
Fixed on trunk.