https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118600
Bug ID: 118600
Summary: Assigning to a record from a constructor can cause an
alignment exception
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: modula2
Assignee: gaius at gcc dot gnu.org
Reporter: gaius at gcc dot gnu.org
Target Milestone: ---
Consider the modula-2 testsuite code:
gcc/testsuite/gm2/iso/run/pass/strcons.mod
MODULE strcons ;
TYPE
NameType = ARRAY [0..24] OF CHAR ;
DateType = RECORD
year, month, day: CARDINAL ;
END ;
PersonType = RECORD
name: NameType ;
DateOfBirth: DateType ;
END ;
VAR
year, month, day: CARDINAL ;
date : DateType ;
person : PersonType ;
BEGIN
date := DateType{year, month, day} ;
date := DateType{1623, 6, 19} ;
person := PersonType{"Blaise Pascal", date} ;
END strcons.
$ 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;
person.name = "Blaise Pascal";
person.DateOfBirth = date;
}
I suspect the misaligned reference to aligned data is occurring during the
string assignment.