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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!mx05.eternal-september.org!feeder.eternal-september.org!xmission!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Elaboration order handling (Was: Bug in 'gnatmake') Date: Tue, 18 Jun 2013 13:09:21 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <7f33982d-3bcf-452e-a3b3-3a0a28505ff1@x20g2000vbe.googlegroups.com> <87r4g0g9c0.fsf@adaheads.sparre-andersen.dk> <87ip1bg4z2.fsf_-_@adaheads.sparre-andersen.dk> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1371575362 18302 192.74.137.71 (18 Jun 2013 17:09:22 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Tue, 18 Jun 2013 17:09:22 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:BOy7CkGvo+sgH0wudS4n/rXVYaQ= Xref: news.eternal-september.org comp.lang.ada:15808 Date: 2013-06-18T13:09:21-04:00 List-Id: Jacob Sparre Andersen writes: > Simon Wright wrote: > >> Don't use -gnatE unless you really really want your code to be >> portable to other compilers. You'd need to expend a lot of extra work >> to include pragmas to ensure that elaboration takes place in an >> appropriate order; GNAT does this for you if you leave out -gnatE. > > I really really want my code to be portable to other compilers. -gnatE doesn't really help with that. -gnatE is for porting code written for other Ada compilers TO GNAT. (It's also for compiling ACATS tests that test the standard Ada elaboration rules.) -gnatE doesn't magically make GNAT use the same order as some other Ada compiler(s). We don't even know what algorithm those compilers use to choose the order, and they're all probably different. All we know is that people trying to port code from one compiler to another have a lot of trouble with elab order. If you want your code to be portable, you need to insert pragma Elaborate_All all over the place. It's nearly impossible to get that right by hand, so you should use the GNAT switch that makes it tell you where Elaborate_All should go. Don't use -gnatE in this case. >...(But I > also use Ada 2012, which currently counters that wish. Feel free to > call me inconsistent.) ;-) > And yes, occassionally I spend some time getting elaboration order > right. What do you mean by "right", and how do you know when you have achieved it? > Is there a reason the GNAT default elaboration ordering hasn't made its > way into the reference manual? I don't think it has ever been seriously considered. It would be an incompatible change, unless we made it a user-controlled option. And it would be a big burden on all those other compilers who implemented (only) the standard Ada rules. It is certainly a big language-design flaw that the elab order is implementation defined. Ada code tends to be pretty portable for the most part, but elab order is one of the top issues that cause non-portability. That and overuse of representation clauses. - Bob