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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:a6b:e413:: with SMTP id u19mr507087iog.34.1555373339058; Mon, 15 Apr 2019 17:08:59 -0700 (PDT) X-Received: by 2002:aca:2d4:: with SMTP id 203mr19912565oic.99.1555373338811; Mon, 15 Apr 2019 17:08:58 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.166.215.MISMATCH!b2no61803itd.0!news-out.google.com!w17ni297itb.0!nntp.google.com!136no62377itk.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 15 Apr 2019 17:08:58 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=137.103.119.68; posting-account=ShYTIAoAAABytvcS76ZrG9GdaV-nXYKy NNTP-Posting-Host: 137.103.119.68 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Why can't objects be static in Ada? From: sbelmont700@gmail.com Injection-Date: Tue, 16 Apr 2019 00:08:59 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:56133 Date: 2019-04-15T17:08:58-07:00 List-Id: For anyone interested, here is a minimal reproduction of what (i think) is the OP's issue (the actual for the generic instantiation, not the constant itself). package Static is pragma Preelaborate; generic type T is private; o : T; package GP is end GP; type T is record x,y : Positive; end record; o : constant T := (others => Positive'First); package p1 is new GP (T, O); --no package p2 is new GP (T, (others => Positive'First)); --yes end Static; gcc -c static.ads static.ads:19:27: non-static constant in preelaborated unit static.ads:19:27: static expression must have scalar or string type (RM 4.9(2)) gnatmake: "static.ads" compilation error Needling to duplicate the declaration does seem needlessly irritating, but then again isn't everything with generics? ;-)