comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Q re pack & aliased
Date: 22 Apr 2003 17:45:09 -0400
Date: 2003-04-22T17:45:09-04:00	[thread overview]
Message-ID: <wccbryyi4uy.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: uy922bg4a.fsf@nasa.gov

Stephen Leake <Stephe.Leake@nasa.gov> writes:

> tmoran@acm.org writes:
> 
> >   I have pre-Gnat 3.15p programs that ran with 24 bit pixels, so this
> > is apparently a new problem.  Would someone with a newer Gnat please
> > try the program below?  
> 
> stephe@anarres$ gnatmake -v testpack.adb 
> 
> GNATMAKE 3.16a (20030120) Copyright 1995-2002 Free Software Foundation, Inc.
>   "testpack.ali" being checked ...
>   -> "testpack.ali" missing.
> gcc -c testpack.adb
> testpack.adb:6:03: warning: pragma "pack" ignored, cannot pack aliased components
> testpack.adb:7:03: warning: "x" is never assigned a value
> End of compilation
> 
> Sorry. Apparently ACT felt the need to improve efficiency somewhere.
> There may be a compiler switch to get back the old behavior. You could
> try reporting it to report@gnat.com as a regression. I don't have any
> older gnat versions handy.

Seems like the old and new behavior are the same.  In both versions, the
compiler refuses to pack aliased 24-bit components.  Or did I
misunderstand the ealier posting?

Anyway, I think what's going on here is that all aliased objects of a
given subtype *must* be represented the same way.  That's because when
you have a pointer in your hands, the compiler doesn't know what it
points to.  The code generated for X.all has to fetch a 24-bit quantity,
not knowing whether it's an array component, or whether the array is
packed.

The most efficient way to fetch 24 bits on this machine is to make sure
the thing is 32-bit aligned, with zeros or sign-extension in the extra 8
bits.  If you insist that the array-of-aliased be tightly packed, then
every X.all would have to be less efficient.  It's fine if references to
components of packed arrays are less efficient.  That's The whole point
of packing -- to allow slowness of array indexing in return for better
speed of copying or comparing the whole array and so forth.  But it's
not fine to make X.all slow even when X points to a component of an
unpacked array, or into the heap.

- Bob



  reply	other threads:[~2003-04-22 21:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-20  1:08 Q re pack & aliased tmoran
2003-04-20 11:40 ` David Holm
2003-04-21  4:44   ` tmoran
2003-04-22 16:08     ` Jacob Sparre Andersen
2003-04-22 16:30       ` Vinzent Hoefler
2003-04-22 16:44         ` tmoran
2003-04-22 17:23           ` Stephen Leake
2003-04-22 21:45             ` Robert A Duff [this message]
2003-04-22 22:25               ` tmoran
2003-04-22 23:10                 ` Nick Roberts
2003-04-23  0:24                   ` tmoran
2003-04-23  8:07                     ` Vinzent Hoefler
2003-04-23 17:18                       ` tmoran
2003-04-23 19:28                         ` Vinzent Hoefler
2003-04-23 11:52                     ` Martin Dowie
2003-04-25 16:06                     ` Nick Roberts
2003-04-25 16:38                       ` Vinzent Hoefler
2003-04-22 22:51           ` Matthew Heaney
2003-04-22 23:16             ` Nick Roberts
replies disabled

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