Bug 18846 - Illegal program accepted, RM 10.2.1(10), 12.3(1.a)
Summary: Illegal program accepted, RM 10.2.1(10), 12.3(1.a)
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: accepts-invalid
Depends on:
Blocks:
 
Reported: 2004-12-05 15:54 UTC by Ludovic Brenta
Modified: 2007-05-02 11:35 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.0.0
Last reconfirmed: 2005-06-14 20:48:19


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludovic Brenta 2004-12-05 15:54:33 UTC
(Debian bug #284333)

-- RM 10.2.1(10):  A generic body is preelaborable only if elaboration
-- of a corresponding instance body would not perform any such actions
-- [assuming the worst about possible actual generic parameters]

-- AARM 12.3(1.a): The legality of an instance should be determinable
-- without looking at the generic body. Likewise, the legality of a
-- generic body should be determinable without looking at any instances.

generic
   x1: integer;
package Test_135 is
   pragma Preelaborate;
   pragma Elaborate_Body;
end Test_135;

package body Test_135 is
   x2: integer := x1;   -- ERROR: not preelaborable
end Test_135;


The compiler is silent; I expect an error message like:

test_135.adb:3:18: object in preelaborated unit has non-static default
gnatmake: "test_135.adb" compilation error
Comment 1 Andrew Pinski 2004-12-05 16:02:54 UTC
Confirmed.
Comment 2 Arnaud Charlet 2007-05-02 11:35:05 UTC
We now get:

$ gcc -c test_135.adb
test_135.adb:3:19: non-static object name in preelaborated unit
test_135.adb:3:19: "x1" is not static constant or named number (RM 4.9(5))

Arno