comp.lang.ada
 help / color / mirror / Atom feed
* GNAT: warning: source alignment....
@ 2001-01-17 16:09 Frode Tenneboe
  2001-01-18  3:35 ` Robert Dewar
  0 siblings, 1 reply; 6+ messages in thread
From: Frode Tenneboe @ 2001-01-17 16:09 UTC (permalink / raw)


In lack of a GNAT specific list, here goes:

I get the following warnings from some legacy code when compilled with GNAT
3.12p:

eh_uif.adb:112:45: warning: source alignment (1) < alignment of "T_WordRec" (2)
eh_uif.adb:113:45: warning: source alignment (1) < alignment of "T_LongRec" (4)
eh_uif.adb:119:47: warning: source alignment (1) < alignment of "T_WordRec" (2)
eh_uif.adb:120:47: warning: source alignment (1) < alignment of "T_LongRec" (4)
eh_uif.adb:163:45: warning: source alignment (1) < alignment of "T_WordRec" (2)
eh_uif.adb:164:45: warning: source alignment (1) < alignment of "T_LongRec" (4)
eh_uif.adb:238:47: warning: source alignment (1) < alignment of "T_WordRec" (2)
eh_uif.adb:239:47: warning: source alignment (1) < alignment of "T_LongRec" (4)

The code (som of it) is as follows:

type T_WordRec is
   record
      w : short_integer;
   end record;
type T_WordPtr is access T_WordRec;
function conv16 is new unchecked_conversion(system.address, T_WordPtr);

WordId : T_WordPtr;
WordId := conv16(UnitId'address);

where UnitId is of:
   type T_UNIT_ITEM is (<>);

I interprete the warning that UnitId is aligned at byte boundaries
whil T_WordRec (nor T_LongRec) is not. Does it make any sense to
use a representation clause on a discrete generic type as above?

Why should the source alignment be an issue here?
I can only find alignment references to target objects - which part of the
RM is this discussed?
What can I do to remove these warnings?

 -Frode
-- 
^ Frode Tenneb�                    | email: ft@edh.ericsson.se      ^
| Ericsson Radar AS. N-1788 Halden |                                |
| Phone: +47 69 21 41 47           | Frode@IRC                      |
| with Standard.Disclaimer; use Standard.Disclaimer;                |



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

* Re: GNAT: warning: source alignment....
  2001-01-17 16:09 GNAT: warning: source alignment Frode Tenneboe
@ 2001-01-18  3:35 ` Robert Dewar
  2001-01-18 13:46   ` Frode Tenneboe
  2001-01-20 19:30   ` DuckE
  0 siblings, 2 replies; 6+ messages in thread
From: Robert Dewar @ 2001-01-18  3:35 UTC (permalink / raw)


In article <979748441.912448@edh3>,
  Frode Tenneboe <ft@alne.edh.ericsson.se> wrote:
> In lack of a GNAT specific list, here goes:
>
> I get the following warnings from some legacy code when
compilled with GNAT
> 3.12p:
>
> eh_uif.adb:112:45: warning: source alignment (1) < alignment
of "T_WordRec" (2)
> eh_uif.adb:113:45: warning: source alignment (1) < alignment
of "T_LongRec" (4)
> eh_uif.adb:119:47: warning: source alignment (1) < alignment
of "T_WordRec" (2)
> eh_uif.adb:120:47: warning: source alignment (1) < alignment
of "T_LongRec" (4)
> eh_uif.adb:163:45: warning: source alignment (1) < alignment
of "T_WordRec" (2)
> eh_uif.adb:164:45: warning: source alignment (1) < alignment
of "T_LongRec" (4)
> eh_uif.adb:238:47: warning: source alignment (1) < alignment
of "T_WordRec" (2)
> eh_uif.adb:239:47: warning: source alignment (1) < alignment
of "T_LongRec" (4)

These warnings are definitely appropriate for the given code.
We have found this particular warning VERY helpful in porting
legacy code.


Sent via Deja.com
http://www.deja.com/



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

* Re: GNAT: warning: source alignment....
  2001-01-18  3:35 ` Robert Dewar
@ 2001-01-18 13:46   ` Frode Tenneboe
  2001-01-18 15:06     ` Robert Dewar
  2001-01-20 19:30   ` DuckE
  1 sibling, 1 reply; 6+ messages in thread
From: Frode Tenneboe @ 2001-01-18 13:46 UTC (permalink / raw)


Robert Dewar <robert_dewar@my-deja.com> wrote:
: In article <979748441.912448@edh3>,
:   Frode Tenneboe <ft@alne.edh.ericsson.se> wrote:
:> eh_uif.adb:239:47: warning: source alignment (1) < alignment
:> of "T_LongRec" (4)

: These warnings are definitely appropriate for the given code.
: We have found this particular warning VERY helpful in porting
: legacy code.

I have no doubts about it, but I'm not sure about exactly
what is going on here. Why does the source alignment have
anything to do with the representation, esp. when dealing
with an unchecked conversion?

I can't find the location in the source where this warning is
produced wither. What about a reference to the RM, or is it
a "nice to have" warning? If so, what are the implications?

 -Frode

-- 
^ Frode Tenneb�                    | email: ft@edh.ericsson.se      ^
| Ericsson Radar AS. N-1788 Halden |                                |
| Phone: +47 69 21 41 47           | Frode@IRC                      |
| with Standard.Disclaimer; use Standard.Disclaimer;                |



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

* Re: GNAT: warning: source alignment....
  2001-01-18 13:46   ` Frode Tenneboe
@ 2001-01-18 15:06     ` Robert Dewar
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Dewar @ 2001-01-18 15:06 UTC (permalink / raw)


In article <979826224.425624@edh3>,
  Frode Tenneboe <ft@alne.edh.ericsson.se> wrote:
> I can't find the location in the source where this warning is
> produced wither. What about a reference to the RM?

Warnings never have anything to do with the RM rules! They are
telling you about constructs that are perfectly legal but are
suspicious, that's all. They simply report a situation which
may be indiciative of an error. If it is not in your case, then
you can simply ignore the warning. As I say, this particular
warning has often corresponded to real problems in ports that
we have done in the past. The proper action to be taken depends
on the situation, and requires detailed analysis.


Sent via Deja.com
http://www.deja.com/



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

* Re: GNAT: warning: source alignment....
  2001-01-18  3:35 ` Robert Dewar
  2001-01-18 13:46   ` Frode Tenneboe
@ 2001-01-20 19:30   ` DuckE
  2001-01-21 16:14     ` Robert Dewar
  1 sibling, 1 reply; 6+ messages in thread
From: DuckE @ 2001-01-20 19:30 UTC (permalink / raw)


>
> These warnings are definitely appropriate for the given code.
> We have found this particular warning VERY helpful in porting
> legacy code.
>

Excuse me Robert, but just which of the questions from the original post did
you answer?

Please choose one:
A)  Does it make any sense to use a representation clause on a discrete
generic type as above?

B) Why should the source alignment be an issue here?

C) I can only find alignment references to target objects - which part of
the RM is this discussed?

D) What can I do to remove these warnings?


As a regular contributor to comp.lang.ada you often contribute meaninful
information to this newsgroup.  In this instance however, you did not.

SteveD
>
> Sent via Deja.com
> http://www.deja.com/





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

* Re: GNAT: warning: source alignment....
  2001-01-20 19:30   ` DuckE
@ 2001-01-21 16:14     ` Robert Dewar
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Dewar @ 2001-01-21 16:14 UTC (permalink / raw)


In article <%Gla6.290393$U46.9219457@news1.sttls1.wa.home.com>,
  "DuckE" <nospam_steved94@home.com> wrote:
> A)  Does it make any sense to use a representation clause on
> a discrete generic type as above?

Sometimes yes, sometimes no, depends on more context than
was shown here.

> B) Why should the source alignment be an issue here?

Alignment is always a potential issue in unchecked conversions
of pointers.

> C) I can only find alignment references to target objects -
> which part of the RM is this discussed?

Alignment is discussed in the RM, this particular warning is
not, warnings have nothing to do with RM rules!

> D) What can I do to remove these warnings?

Depends on the particular context, as with all warnings, you
are just being given some potentially useful information. It
is up to you to analyze whether the information is useful
in that it points up a real problem.

If it points up a real problem, then fix the warning, if it
does not point up a real problem, then suppress the warning
(that's a generic comment on all warning messages).

The warning is saying nothing more nor nothing less than it
says. It is just conveying information that may be helpful in
pointing out a potential error situation (in this case a
problem with incorrect alignments).

> As a regular contributor to comp.lang.ada you often
> contribute meaninful information to this newsgroup.  In this
> instance however, you did not.

Impossible to give more meaningful information without further
context. A detailed analysis of the particular situation in the
particular application is needed. Certainly I spend quite a bit
of time on such detailed analyses in other situations, but
detailed analysis of other peoples application problems is
outside the scope of what I contribute to CLA!


Sent via Deja.com
http://www.deja.com/



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

end of thread, other threads:[~2001-01-21 16:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-17 16:09 GNAT: warning: source alignment Frode Tenneboe
2001-01-18  3:35 ` Robert Dewar
2001-01-18 13:46   ` Frode Tenneboe
2001-01-18 15:06     ` Robert Dewar
2001-01-20 19:30   ` DuckE
2001-01-21 16:14     ` Robert Dewar

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