[Bug modula2/118600] Assigning to a record from a constructor can cause an alignment exception
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 20 20:11:06 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118600
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Gaius Mulley <gaius@gcc.gnu.org>:
https://gcc.gnu.org/g:d286ece094ca52f41bf71096aa1de0a0cd954dfb
commit r15-8475-gd286ece094ca52f41bf71096aa1de0a0cd954dfb
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date: Thu Mar 20 20:10:31 2025 +0000
PR modula2/118600 Assigning to a record causes alignment exception
This patch recursively tests every assignment (of a constructor
to a designator) to ensure the types are GCC equivalent. If they
are equivalent then it uses gimple assignment and if not then it
copies a structure by field and uses __builtin_strncpy to copy a
string cst into an array. Unions are copied by __builtin_memcpy.
gcc/m2/ChangeLog:
PR modula2/118600
* gm2-compiler/M2GenGCC.mod (PerformCodeBecomes): New procedure.
(CodeBecomes): Refactor and call PerformCodeBecomes.
* gm2-gcc/m2builtins.cc (gm2_strncpy_node): New global variable.
(DoBuiltinStrNCopy): New function.
(m2builtins_BuiltinStrNCopy): New function.
(m2builtins_init): Initialize gm2_strncpy_node.
* gm2-gcc/m2builtins.def (BuiltinStrNCopy): New procedure
function.
* gm2-gcc/m2builtins.h (m2builtins_BuiltinStrNCopy): New
function.
* gm2-gcc/m2statement.cc (copy_record_fields): New function.
(copy_array): Ditto.
(copy_strncpy): Ditto.
(copy_memcpy): Ditto.
(CopyByField_Lower): Ditto.
(m2statement_CopyByField): Ditto.
* gm2-gcc/m2statement.def (CopyByField): New procedure function.
* gm2-gcc/m2statement.h (m2statement_CopyByField): New function.
* gm2-gcc/m2type.cc (check_record_fields): Ditto.
(check_array_types): Ditto.
(m2type_IsGccStrictTypeEquivalent): Ditto.
* gm2-gcc/m2type.def (IsGccStrictTypeEquivalent): New procedure
function.
* gm2-gcc/m2type.h (m2type_IsAddress): Replace return type int
with bool.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
More information about the Gcc-bugs
mailing list