[Bug modula2/118600] Assigning to a record from a constructor can cause an alignment exception

gaius at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 22 01:17:13 GMT 2025


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118600

--- Comment #1 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 60236
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60236&action=edit
PR-118600-Assigning-to-a-record-causes-alignment-exception.patch

Proposed fix.  This exploratory proposed fix tests to see if the assignment lhs
and rhs types are GCC equivalent.  If rhs and rhs are not GCC equivalent then
it copies records by fields and uses __builtin_strncpy to copy strings into
arrays.

$ gm2 -fm2-dump=all -fdump-lang-all strcons.mod  -fdump-tree-all
$ cat a-strcons.mod.007t.gimple

PROC _M2_strcons_init (INTEGER argc, PROC * argv, PROC * envp)
{
  year.0_1 = year;
  date.year = year.0_1;
  month.1_2 = month;
  date.month = month.1_2;
  day.2_3 = day;
  date.day = day.2_3;
  date.year = 1623;
  date.month = 6;
  date.day = 19;
  __builtin_strncpy (&person.name, "Blaise Pascal", 14);
  person.DateOfBirth = date;
}


More information about the Gcc-bugs mailing list