This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PRs 52080, 52097 and 48124, rewrite bitfield expansion, enable the C++ memory model wrt bitfields everywhere


> Ok, I applied a fix for PR52134 and am preparing a fix for PR52578.
> It seems we might not be able to rely on
>
>       tree maxsize = size_diffop (TYPE_SIZE_UNIT (DECL_CONTEXT (field)),
>                                   DECL_FIELD_OFFSET (repr));
>       gcc_assert (host_integerp (maxsize, 1));
>
> but at least until we get a testcase that shows so I won't add
> (unexercised) code that handles it.  Eventually we'd need to treat
> tail-padding specially for some languages anyway, via a new langhook.

This caused 3 classes of problems in Ada:

  1. failure of the above assertion (pack7.ads)
  2. ICE in tree_low_cst (pack16.adb, pack16_pkg.ads)
  3. miscompilation (to be dealt with later).

1. and 2. appear to come from variable-sized fields (and 3. from record types 
with variant part).  Testcases attached, they can be installed as:

  gnat.dg/pack16.adb
  gnat.dg/pack16_pkg.ads
  gnat.dg/specs/pack7.ads

in the testsuite.

-- 
Eric Botcazou
-- { dg-do compile }
-- { dg-options "-gnatws" }

with Pack16_Pkg; use Pack16_Pkg;

procedure Pack16 is

   type Sample_Table_T is array (1 .. N) of Integer;

   type Clock_T is record
      N_Ticks  : Integer := 0;
   end record;

   type Sampling_Descriptor_T is record
      Values : Sample_Table_T;
      Valid  : Boolean;
      Tstamp : Clock_T;
   end record;

   pragma Pack (Sampling_Descriptor_T);

   Sampling_Data : Sampling_Descriptor_T;

begin
   null;
end;
package Pack16_Pkg is

   N : Natural := 16;

end Pack16_Pkg;
-- { dg-do compile }

package Pack7 is

   type R (D : Natural) is record
      S : String (1 .. D);
      N : Natural;
      B : Boolean;
   end record;
   for R'Alignment use 4;
   pragma Pack (R);

end Pack7;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]