comp.lang.ada
 help / color / mirror / Atom feed
From: Justin Gombos <bogus_addy@bogus_domain.net>
Subject: Re: pragma Convention ignored (sometimes)
Date: Sat, 05 Nov 2005 02:54:34 GMT
Date: 2005-11-05T02:54:34+00:00	[thread overview]
Message-ID: <slrndmoeoh.b6j.bogus_addy@tango.mindfuq.org> (raw)
In-Reply-To: lbCaf.5450$Rl1.1293@newsread1.news.pas.earthlink.net

In article <lbCaf.5450$Rl1.1293@newsread1.news.pas.earthlink.net>, Jeffrey R. Carter wrote:
> 
> By default, 'Size on a subtype gives the minimum # of bits to
> represent the values of the type. In this case, that would be
> 2. 'Size of an object is something else, and in this case is
> probably more like what you expect. Without the pragma Convention,
> I'd expect it to be 8 on x86 targets.

Why would 'size on a four element enum return a different number than
a 'size on a three element enum?  Regardless of whether 'size reports
object size or value size, it should not give me inconsistent
answers.  

At the moment I'm having trouble reconstructing this problem in an
isolated example, but I know I witnessed a case (when I was at work)
where 'size reported 8 bits for one enum, and 32 bits for another
comparably sized enum (like around five elements), both of which had a
pragma Convention clause.  

You're not suggesting that 'size reports object size in some cases,
and value size in other cases, are you?  (btw- I intend to stop
printing 'size with the ADA_IO package now that I know about -gnatR).

I'll see if I can isolate a case where pragma Convention fails later.
In the meantime, here's a working working example:

When this code:

   procedure Enum is

      type My_Enum is (One, Two, Three);
      
   begin
      null;
   end Enum;

is compiled with -gnatR3, gcc produces:

   $ gcc -c -gnatR3 enum.adb
    
   Representation information for unit Enum (body)
   -----------------------------------------------
    
   for My_Enum'Object_Size use 8;
   for My_Enum'Value_Size use 2;
   for My_Enum'Alignment use 1;

while this code:

   procedure Enum is

      type My_Enum is (One, Two, Three);
      
      --The following line *sometimes* does what's expected.
      --
      pragma Convention (Convention => C, Entity => My_Enum);
      
   begin
      null;
   end Enum;

produces:

   $ gcc -c -gnatR3 enum.adb
    
   Representation information for unit Enum (body)
   -----------------------------------------------
    
   for My_Enum'Object_Size use 32;
   for My_Enum'Value_Size use 2;
   for My_Enum'Alignment use 4;
    
So that's a case where pragma Convention works as I expect.  There are
a couple cases where I had to brute forcefully specify:

   for My_Enum'Size use 32;

despite the pragma Convention, which suggests that pragma convention
is unpredicable.



  reply	other threads:[~2005-11-05  2:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-03 15:03 Gnat 3.15p pragma issues Erik Woulfe
2005-11-03 16:00 ` Colin Paul Gloster
2005-11-03 22:56   ` Robert A Duff
2005-11-04  2:12     ` pragma Convention ignored (sometimes) Anonymous Coward
2005-11-04  5:19       ` Jeffrey R. Carter
2005-11-05  2:54         ` Justin Gombos [this message]
2005-11-03 17:42 ` Gnat 3.15p pragma issues Gautier Write-only
2005-11-03 23:00 ` Robert A Duff
2005-11-04  2:51 ` Steve
2005-11-04 13:02 ` Stephen Leake
replies disabled

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