From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,92f1b9f519795959 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!cycny01.gnilink.net!cyclone1.gnilink.net!spamkiller.gnilink.net!gnilink.net!trnddc04.POSTED!20ae255c!not-for-mail Newsgroups: comp.lang.ada From: Justin Gombos Subject: Re: pragma Convention ignored (sometimes) References: <1131029395.700984.154230@f14g2000cwb.googlegroups.com> Message-Id: User-Agent: slrn/0.9.7.4 (Linux) Date: Sat, 05 Nov 2005 02:54:34 GMT NNTP-Posting-Host: 141.149.78.234 X-Complaints-To: abuse@verizon.net X-Trace: trnddc04 1131159274 141.149.78.234 (Fri, 04 Nov 2005 21:54:34 EST) NNTP-Posting-Date: Fri, 04 Nov 2005 21:54:34 EST Xref: g2news1.google.com comp.lang.ada:6219 Date: 2005-11-05T02:54:34+00:00 List-Id: In article , 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.