comp.lang.ada
 help / color / mirror / Atom feed
* subtype of System.Address type
@ 2014-02-27  5:19 ashwath30jul77
  2014-02-27  5:38 ` Shark8
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: ashwath30jul77 @ 2014-02-27  5:19 UTC (permalink / raw)


Hello,
My compiler(GNAT 3.1 ) gives an error for the following statement.

 subtype MEMORY_RANGE_TYPE is SYSTEM.ADDRESS range 16#0000_0000#..16#7FFF_FFFF#;

It says incorrect constraint for this type.

Kindly let me know the mistake I am doing.

Thanks in Advance
Ashwath

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: subtype of System.Address type
  2014-02-27  5:19 subtype of System.Address type ashwath30jul77
@ 2014-02-27  5:38 ` Shark8
  2014-02-27  6:07 ` Jeffrey Carter
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Shark8 @ 2014-02-27  5:38 UTC (permalink / raw)


GNAT has the following public definition for System.Address:
      type Address is private;

This means that your code doesn't know that the actual implementation is:
   type Address is mod Memory_Size;

And therefore you cannot assign a universal-integer to Address. {Because you, as a client of System, cannot depend on its implementation-details.}


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: subtype of System.Address type
  2014-02-27  5:19 subtype of System.Address type ashwath30jul77
  2014-02-27  5:38 ` Shark8
@ 2014-02-27  6:07 ` Jeffrey Carter
  2014-02-27 15:33   ` Robert A Duff
  2014-02-27 11:25 ` Brian Drummond
  2014-02-27 16:06 ` adambeneschan
  3 siblings, 1 reply; 6+ messages in thread
From: Jeffrey Carter @ 2014-02-27  6:07 UTC (permalink / raw)


On 02/26/2014 10:19 PM, ashwath30jul77@gmail.com wrote:
> Hello,
> My compiler(GNAT 3.1 ) gives an error for the following statement.
>
>   subtype MEMORY_RANGE_TYPE is SYSTEM.ADDRESS range 16#0000_0000#..16#7FFF_FFFF#;
>
> It says incorrect constraint for this type.
>
> Kindly let me know the mistake I am doing.

I don't know about GNAT 3.1, but in more recent versions of GNAT, System.Address 
is not a numeric type.

-- 
Jeff Carter
"I unclog my nose towards you."
Monty Python & the Holy Grail
11


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: subtype of System.Address type
  2014-02-27  5:19 subtype of System.Address type ashwath30jul77
  2014-02-27  5:38 ` Shark8
  2014-02-27  6:07 ` Jeffrey Carter
@ 2014-02-27 11:25 ` Brian Drummond
  2014-02-27 16:06 ` adambeneschan
  3 siblings, 0 replies; 6+ messages in thread
From: Brian Drummond @ 2014-02-27 11:25 UTC (permalink / raw)


On Wed, 26 Feb 2014 21:19:57 -0800, ashwath30jul77 wrote:

> Hello,
> My compiler(GNAT 3.1 ) gives an error for the following statement.
> 
>  subtype MEMORY_RANGE_TYPE is SYSTEM.ADDRESS range
>  16#0000_0000#..16#7FFF_FFFF#;
> 
> It says incorrect constraint for this type.

What makes you think SYSTEM.ADDRESS is 32 bits, or even a single quantity 
rather than a tuple(segment,offset) or something else?

- Brian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: subtype of System.Address type
  2014-02-27  6:07 ` Jeffrey Carter
@ 2014-02-27 15:33   ` Robert A Duff
  0 siblings, 0 replies; 6+ messages in thread
From: Robert A Duff @ 2014-02-27 15:33 UTC (permalink / raw)


Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org> writes:

> I don't know about GNAT 3.1, but in more recent versions of GNAT,
> System.Address is not a numeric type.

System.Address has always been a private type in GNAT, except perhaps
in the VMS version.

Why not upgrade to a more recent version?  3.1 is very old, and many
improvements have been made to GNAT since then.

It was common for Ada 83 compilers to use an integer type for Address,
but the Ada 95 RM recommends (but does not require) that it be a private
type.

- Bob


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: subtype of System.Address type
  2014-02-27  5:19 subtype of System.Address type ashwath30jul77
                   ` (2 preceding siblings ...)
  2014-02-27 11:25 ` Brian Drummond
@ 2014-02-27 16:06 ` adambeneschan
  3 siblings, 0 replies; 6+ messages in thread
From: adambeneschan @ 2014-02-27 16:06 UTC (permalink / raw)


On Wednesday, February 26, 2014 9:19:57 PM UTC-8, ashwath...@gmail.com wrote:
> Hello,
> 
> My compiler(GNAT 3.1 ) gives an error for the following statement.
> 
> 
> 
>  subtype MEMORY_RANGE_TYPE is SYSTEM.ADDRESS range 16#0000_0000#..16#7FFF_FFFF#; 
> 
> It says incorrect constraint for this type.
> 
> Kindly let me know the mistake I am doing.

Like everyone else said, System.Address is a private type.  If you really need to use integers as addresses, use System.Storage_Elements.Integer_Address:

   subtype Memory_Range_Type is System.Storage_Elements.Integer_Address range
      16#0000_0000# .. 16#7FFF_FFFF#;

Integer_Address is required to be either a signed or modular integer subtype; either way, the above will work as long as both 0 and 7FFFFFFF are in range for the implementation-defined subtype.  Then, System.Storage_Elements.To_Address(Value) will convert an Integer_Address to a System.Address.  See RM 13.7.1.  (This package has been part of the language since Ada 95.)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-02-27 16:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-27  5:19 subtype of System.Address type ashwath30jul77
2014-02-27  5:38 ` Shark8
2014-02-27  6:07 ` Jeffrey Carter
2014-02-27 15:33   ` Robert A Duff
2014-02-27 11:25 ` Brian Drummond
2014-02-27 16:06 ` adambeneschan

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