Here we crash because we attempt to % by 0. Thus fixed.
PR c++/105634
gcc/cp/ChangeLog:
* call.cc (maybe_warn_class_memaccess): Avoid % by zero.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wclass-memaccess-7.C: New test.
/* Finally, warn on partial copies. */
unsigned HOST_WIDE_INT typesize
= tree_to_uhwi (TYPE_SIZE_UNIT (desttype));
+ if (typesize == 0)
+ break;
if (unsigned HOST_WIDE_INT partial = tree_to_uhwi (sz) % typesize)
warned = warning_at (loc, OPT_Wclass_memaccess,
(typesize - partial > 1
--- /dev/null
+// PR c++/105634
+// { dg-do compile { target { c++11 } } }
+// { dg-options "-Wall" }
+
+struct s
+{
+ struct {} a[] = 1.0; // { dg-error "" }
+ void f (char *c)
+ {
+ s s;
+ __builtin_memcpy (&s, c, sizeof(s));
+ }
+};