From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,de8112bdf65b223b,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.180.81.8 with SMTP id v8mr1835319wix.7.1360478451777; Sat, 09 Feb 2013 22:40:51 -0800 (PST) Path: g1ni2223wig.0!nntp.google.com!feeder1.cambriumusenet.nl!82.197.223.103.MISMATCH!feeder3.cambriumusenet.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsgate.cuhk.edu.hk!news.glorb.com!feeder.erje.net!us.feeder.erje.net!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Inheritance of representation aspects Date: Sun, 03 Feb 2013 16:27:20 +0000 Organization: A noiseless patient Spider Message-ID: Mime-Version: 1.0 Injection-Info: mx05.eternal-september.org; posting-host="c8da4aa61d590a5e477a2e03e552a940"; logging-data="32184"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193CBG2/dapPPlVKcMxExHlY77aB1HQZfk=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (darwin) Cancel-Lock: sha1:h7w9eT8/1Lks0tQ6yNM0BQych4M= sha1:VqAJtFrFJhLZJkcj/x1S+wZh6uo= Content-Type: text/plain Date: 2013-02-03T16:27:20+00:00 List-Id: A question on Stack Overflow[1] asks about deriving from an unchecked union. The questioner thinks that a derived type should also be an unchecked union, but GNAT doesn't. A demo is package Union is type Access_Kind is (Named, Indexed); type Array_Type is array (0 .. 1) of Integer; type Base (Kind : Access_Kind := Access_Kind'First) is record case Kind is when Named => X, Y : Integer; when Indexed => S : Array_Type; end case; end record with Unchecked_Union => True, Convention => C_Pass_By_Copy; -- A primitive operation, freezes Base. procedure P (R : Base) is null; -- Derived types should inherit both representation aspects, so -- both these aspects should be confirming. type Derived_1 is new Base with Unchecked_Union => True; type Derived_2 is new Base with Convention => C_Pass_By_Copy; -- This should fail (ARM 13.1(10)). type Derived_3 is new Base with Unchecked_Union => False; end Union; Both Unchecked_Union and C_Pass_By_Copy are representation aspects, and should therefore be inherited (I've given links at my SO answer[2]). So the aspects specified for Derived_1 and Derived_2 should both be confirming and therefore OK (?), while the aspect for Derived_3 should be illegal by ARM 13.1(10). With GNAT GPL 2012 and GCC 4.8.0 (r195682), Derived_1 and Derived_2 fail (representation item appears too late) and Derived_3 doesn't raise an error. With GNAT GPL 2012, if I comment out Derived_1 and Derived_2, the compilation is successful (with 4.8.0 I get a bug box, which is a separate issue). Am I correct that these aspects should be inherited? [1] http://stackoverflow.com/questions/14663316/derive-from-unchecked-union [2] http://stackoverflow.com/questions/14663316/derive-from-unchecked-union/14671548#14671548