comp.lang.ada
 help / color / mirror / Atom feed
From: sbelmont700@gmail.com
Subject: Re: Why can't objects be static in Ada?
Date: Mon, 15 Apr 2019 17:08:58 -0700 (PDT)
Date: 2019-04-15T17:08:58-07:00	[thread overview]
Message-ID: <bc07b54c-0e86-4a40-931c-ca52d0295564@googlegroups.com> (raw)
In-Reply-To: <b411a770-5e86-4d5e-9e43-e52843be724d@googlegroups.com>

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? ;-)

  parent reply	other threads:[~2019-04-16  0:08 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11 12:40 Why can't objects be static in Ada? Lucretia
2019-04-11 12:56 ` Mark Lorenzen
2019-04-11 13:31   ` Lucretia
2019-04-11 22:49 ` Randy Brukardt
2019-04-12  1:56   ` Lucretia
2019-04-12  7:33     ` Dmitry A. Kazakov
2019-04-12 22:38     ` Randy Brukardt
2019-04-13  9:14       ` Lucretia
2019-04-12  6:59   ` Mark Lorenzen
2019-04-12  8:12     ` Simon Wright
2019-04-12 22:02     ` Randy Brukardt
2019-04-13 13:07 ` Jere
2019-04-13 13:48   ` Lucretia
2019-04-15 17:46     ` G. B.
2019-04-14  3:47 ` Keith Thompson
2019-04-16  0:08 ` sbelmont700 [this message]
2019-04-16  1:40   ` Randy Brukardt
2019-04-16 12:11     ` Mark Lorenzen
2019-04-16 16:19       ` Simon Wright
2019-04-16 20:56       ` Lucretia
2019-04-16 21:07         ` Niklas Holsti
2019-04-16 21:16           ` Lucretia
2019-04-16 21:40             ` Niklas Holsti
2019-04-16 23:26             ` Randy Brukardt
2019-04-23 14:30           ` Mark Lorenzen
2019-04-16 23:09       ` Randy Brukardt
2019-04-22 20:05       ` Norman Worth
2019-04-16 20:54     ` Lucretia
2019-04-16 23:15       ` Randy Brukardt
2019-04-16 20:53   ` Lucretia
2019-04-18 13:32 ` sbelmont700
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox