[Bug c++/105634] [9/10/11/12/13 Regression] ICE: Floating point exception in maybe_warn_class_memaccess

2022-05-18 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105634

--- Comment #3 from CVS Commits  ---
The trunk branch has been updated by Marek Polacek :

https://gcc.gnu.org/g:dfe38b8d5dbfe3dd5209aece4ce2f7a6b303a2f9

commit r13-621-gdfe38b8d5dbfe3dd5209aece4ce2f7a6b303a2f9
Author: Marek Polacek 
Date:   Tue May 17 15:13:58 2022 -0400

c++: fix SIGFPE with -Wclass-memaccess [PR105634]

Here we crash because we attempt to % by 0.  Thus fixed.
While at it, I've moved the -Wclass-memaccess tests into warn/.
I've checked that the # of expected passes is the same before/after
the move.

PR c++/105634

gcc/cp/ChangeLog:

* call.cc (maybe_warn_class_memaccess): Avoid % by zero.

gcc/testsuite/ChangeLog:

* g++.dg/Wclass-memaccess-2.C: Moved to...
* g++.dg/warn/Wclass-memaccess-2.C: ...here.
* g++.dg/Wclass-memaccess-3.C: Moved to...
* g++.dg/warn/Wclass-memaccess-3.C: ...here.
* g++.dg/Wclass-memaccess-4.C: Moved to...
* g++.dg/warn/Wclass-memaccess-4.C: ...here.
* g++.dg/Wclass-memaccess-5.C: Moved to...
* g++.dg/warn/Wclass-memaccess-5.C: ...here.
* g++.dg/Wclass-memaccess-6.C: Moved to...
* g++.dg/warn/Wclass-memaccess-6.C: ...here.
* g++.dg/Wclass-memaccess.C: Moved to...
* g++.dg/warn/Wclass-memaccess.C: ...here.
* g++.dg/warn/Wclass-memaccess-7.C: New test.

[Bug c++/105634] [9/10/11/12/13 Regression] ICE: Floating point exception in maybe_warn_class_memaccess

2022-05-17 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105634

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

--- Comment #2 from Marek Polacek  ---
Fix:

--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -10329,6 +10329,8 @@ maybe_warn_class_memaccess (location_t loc, tree
fndecl,
  /* 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

[Bug c++/105634] [9/10/11/12/13 Regression] ICE: Floating point exception in maybe_warn_class_memaccess

2022-05-17 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105634

Marek Polacek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Target Milestone|--- |9.5
 CC||mpolacek at gcc dot gnu.org
Summary|ICE: Floating point |[9/10/11/12/13 Regression]
   |exception in|ICE: Floating point
   |maybe_warn_class_memaccess  |exception in
   ||maybe_warn_class_memaccess
   Priority|P3  |P5
   Keywords||error-recovery
   Last reconfirmed||2022-05-17
 Ever confirmed|0   |1

--- Comment #1 from Marek Polacek  ---
Started with r249234:

commit c3684b7b86da9b6b01f6fb274227fc6401df053e
Author: Martin Sebor 
Date:   Fri Jun 16 03:48:59 2017 +

PR c++/80560 - warn on undefined memory operations involving non-trivial
types