]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Fix run-time SIGSEGV reading ModuleInfo.flags()
authorIain Buclaw <ibuclaw@gdcproject.org>
Sun, 31 Mar 2019 14:34:41 +0000 (14:34 +0000)
committerIain Buclaw <ibuclaw@gcc.gnu.org>
Sun, 31 Mar 2019 14:34:41 +0000 (14:34 +0000)
The current forced alignment is not necessary, and is problematic on
targets that have strict alignment rules.

gcc/d/ChangeLog:

2019-03-31  Iain Buclaw  <ibuclaw@gdcproject.org>

PR d/88462
* modules.cc (layout_moduleinfo_fields): Properly align ModuleInfo,
instead of forcing alignment to be 1.

From-SVN: r270043

gcc/d/ChangeLog
gcc/d/modules.cc

index 39df9b8aac0ad21f694c170ef78cf7eb97f9675b..bb2a2370467569f9e8cbcf0929355d8c2a925703 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-31  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+       PR d/88462
+       * modules.cc (layout_moduleinfo_fields): Properly align ModuleInfo,
+       instead of forcing alignment to be 1.
+
 2019-03-21  Iain Buclaw  <ibuclaw@gdcproject.org>
 
        PR d/89017
index a1fc534c3b6b29ca9ce4b4c7bcb751ba0fb74830..e9bd44115f9160d7171f820585f232c87ee1cec9 100644 (file)
@@ -534,7 +534,9 @@ layout_moduleinfo_fields (Module *decl, tree type)
   layout_moduleinfo_field (make_array_type (Type::tchar, namelen),
                           type, offset);
 
-  finish_aggregate_type (offset, 1, type, NULL);
+  size_t alignsize = MAX (TYPE_ALIGN_UNIT (type),
+                         TYPE_ALIGN_UNIT (ptr_type_node));
+  finish_aggregate_type (offset, alignsize, type, NULL);
 
   return type;
 }