Bug 17954 - Missing diagnostic for ill-placed pragma Pack
Summary: Missing diagnostic for ill-placed pragma Pack
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 3.4.2
: P2 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2004-10-12 18:54 UTC by Ludovic Brenta
Modified: 2016-10-03 05:51 UTC (History)
3 users (show)

See Also:
Host: i486-linux
Target: i486-linux
Build: i486-linux
Known to work:
Known to fail:
Last reconfirmed: 2005-06-14 20:31:06


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludovic Brenta 2004-10-12 18:54:13 UTC
Debian Bug #276227:

-- interestingly, the error message is different depending on
-- the number of enumeration elements in T1 and T2.
package Test_124 is
   type T1 is (b01,b02,b03,b04,b05,b06,b07,b08,b09,b10,
               b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,
               b21,b22,b23,b24,b25,b26,b27,b28,b29,b30,
               b31,b32);

   type T1_arr_unconstrained is array (T1 range <>) of boolean;
   type T1_arr_constrained is new T1_arr_unconstrained (T1);
   pragma pack (T1_arr_unconstrained);
   for T1_arr_constrained'size use 32; -- line 12

   type T2 is (b01,b02,b03,b04,b05,b06,b07,b08,b09,b10,
               b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,
               b21,b22,b23,b24,b25,b26,b27,b28,b29,b30,
               b31);   -- one fewer than T1

   type T2_arr_unconstrained is array (T2 range <>) of boolean;
   type T2_arr_constrained is new T2_arr_unconstrained (T2);
   pragma pack (T2_arr_unconstrained);
   for T2_arr_constrained'size use 32; -- line 22
end Test_124;


The actual output from GCC 3.4.2 is:

test_124.ads:12:04: size given for "T1_arr_constrained" too small
test_124.ads:12:04: explicit pragma Pack is required
gnatmake: "test_124.ads" compilation error

If line 12 is commented out:

test_124.ads:22:36: size for "T2_arr_constrained" too small, minimum allowed is 248
gnatmake: "test_124.ads" compilation error
Comment 1 Andrew Pinski 2004-11-01 01:40:31 UTC
Confirmed.
Comment 2 Nicolas Boulenguez 2011-08-31 12:41:28 UTC
From: Jörgen Tegnér <jorgen.tegner@telia.com>
The compiler message is different with 4.3.2-2. Now it reads
test_124.ads:12:36: size for "T1_arr_constrained" too small, minimum
allowed is 256
test_124.ads:22:36: size for "T2_arr_constrained" too small, minimum
allowed is 248

I get the same results with 4.6.1, so I propose to test only one type.
package Test_124 is                                                             
   type T is range 1 .. 32;                                                     
   type T_arr_unconstrained is array (T range <>) of boolean;                   
   type T_arr_constrained is new T_arr_unconstrained (T);                       
   pragma pack (T_arr_unconstrained);                                           
   for T_arr_constrained'size use 32;                                           
end Test_124;
Comment 3 Nicolas Boulenguez 2014-02-27 18:46:32 UTC
Found in 4.9-20140218
Comment 4 Eric Botcazou 2015-12-05 10:52:44 UTC
I think that the program is illegal since the pragma Pack comes too late.