public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105634] New: ICE: Floating point exception in maybe_warn_class_memaccess
@ 2022-05-17 18:46 gscfq@t-online.de
  2022-05-17 19:01 ` [Bug c++/105634] [9/10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: gscfq@t-online.de @ 2022-05-17 18:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105634

            Bug ID: 105634
           Summary: ICE: Floating point exception in
                    maybe_warn_class_memaccess
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Started with r8 :


$ cat z1.cc
struct s
{
  struct {} a[] = 1.0;
  void f (char *c)
  {
    s s;
    __builtin_memcpy (&s, c, sizeof(s));
  }
};


$ g++-13-20220515 -c z1.cc -Wall
z1.cc:3:13: error: flexible array member 's::a' in an otherwise empty 'struct
s'
    3 |   struct {} a[] = 1.0;
      |             ^
z1.cc:3:13: error: initializer for flexible array member 's::<unnamed struct>
s::a []'
z1.cc: In member function 'void s::f(char*)':
z1.cc:7:22: internal compiler error: Floating point exception
    7 |     __builtin_memcpy (&s, c, sizeof(s));
      |     ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
0x10da4cf crash_signal
        ../../gcc/toplev.cc:322
0x736147 maybe_warn_class_memaccess
        ../../gcc/cp/call.cc:10332
0x736147 build_over_call
        ../../gcc/cp/call.cc:9880
0x736a87 build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ../../gcc/cp/call.cc:4847
0x9ecc5e finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ../../gcc/cp/semantics.cc:2895
0x91b288 cp_parser_postfix_expression
        ../../gcc/cp/parser.cc:7888
0x932a91 cp_parser_unary_expression
        ../../gcc/cp/parser.cc:9037
0x90017f cp_parser_cast_expression
        ../../gcc/cp/parser.cc:9941
0x900a41 cp_parser_binary_expression
        ../../gcc/cp/parser.cc:10043
0x901470 cp_parser_assignment_expression
        ../../gcc/cp/parser.cc:10347
0x90315c cp_parser_expression
        ../../gcc/cp/parser.cc:10517
0x906597 cp_parser_expression_statement
        ../../gcc/cp/parser.cc:12734
0x916ab4 cp_parser_statement
        ../../gcc/cp/parser.cc:12526
0x917c94 cp_parser_statement_seq_opt
        ../../gcc/cp/parser.cc:12883
0x917d77 cp_parser_compound_statement
        ../../gcc/cp/parser.cc:12835
0x93ea00 cp_parser_function_body
        ../../gcc/cp/parser.cc:25186
0x93ea00 cp_parser_ctor_initializer_opt_and_function_body
        ../../gcc/cp/parser.cc:25237
0x93f07a cp_parser_function_definition_after_declarator
        ../../gcc/cp/parser.cc:31369
0x93f430 cp_parser_late_parsing_for_member
        ../../gcc/cp/parser.cc:32335
0x911802 cp_parser_class_specifier_1
        ../../gcc/cp/parser.cc:26305

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/105634] [9/10/11/12/13 Regression] ICE: Floating point exception in maybe_warn_class_memaccess
  2022-05-17 18:46 [Bug c++/105634] New: ICE: Floating point exception in maybe_warn_class_memaccess gscfq@t-online.de
@ 2022-05-17 19:01 ` mpolacek at gcc dot gnu.org
  2022-05-17 19:05 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-05-17 19:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105634

Marek Polacek <mpolacek at gcc dot gnu.org> 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 <mpolacek at gcc dot gnu.org> ---
Started with r249234:

commit c3684b7b86da9b6b01f6fb274227fc6401df053e
Author: Martin Sebor <msebor@redhat.com>
Date:   Fri Jun 16 03:48:59 2017 +0000

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/105634] [9/10/11/12/13 Regression] ICE: Floating point exception in maybe_warn_class_memaccess
  2022-05-17 18:46 [Bug c++/105634] New: ICE: Floating point exception in maybe_warn_class_memaccess gscfq@t-online.de
  2022-05-17 19:01 ` [Bug c++/105634] [9/10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
@ 2022-05-17 19:05 ` mpolacek at gcc dot gnu.org
  2022-05-18 14:33 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-05-17 19:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105634

Marek Polacek <mpolacek at gcc dot gnu.org> 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 <mpolacek at gcc dot gnu.org> ---
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/105634] [9/10/11/12/13 Regression] ICE: Floating point exception in maybe_warn_class_memaccess
  2022-05-17 18:46 [Bug c++/105634] New: ICE: Floating point exception in maybe_warn_class_memaccess gscfq@t-online.de
  2022-05-17 19:01 ` [Bug c++/105634] [9/10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
  2022-05-17 19:05 ` mpolacek at gcc dot gnu.org
@ 2022-05-18 14:33 ` cvs-commit at gcc dot gnu.org
  2022-05-18 14:36 ` [Bug c++/105634] [9/10/11/12 " mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-18 14:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105634

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

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

commit r13-621-gdfe38b8d5dbfe3dd5209aece4ce2f7a6b303a2f9
Author: Marek Polacek <polacek@redhat.com>
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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/105634] [9/10/11/12 Regression] ICE: Floating point exception in maybe_warn_class_memaccess
  2022-05-17 18:46 [Bug c++/105634] New: ICE: Floating point exception in maybe_warn_class_memaccess gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-05-18 14:33 ` cvs-commit at gcc dot gnu.org
@ 2022-05-18 14:36 ` mpolacek at gcc dot gnu.org
  2022-07-19 17:13 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-05-18 14:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105634

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
            Summary|[9/10/11/12/13 Regression]  |[9/10/11/12 Regression]
                   |ICE: Floating point         |ICE: Floating point
                   |exception in                |exception in
                   |maybe_warn_class_memaccess  |maybe_warn_class_memaccess

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed for GCC 13, not backporting.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/105634] [9/10/11/12 Regression] ICE: Floating point exception in maybe_warn_class_memaccess
  2022-05-17 18:46 [Bug c++/105634] New: ICE: Floating point exception in maybe_warn_class_memaccess gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-05-18 14:36 ` [Bug c++/105634] [9/10/11/12 " mpolacek at gcc dot gnu.org
@ 2022-07-19 17:13 ` mpolacek at gcc dot gnu.org
  2022-07-19 18:25 ` cvs-commit at gcc dot gnu.org
  2022-07-19 18:26 ` [Bug c++/105634] [9/10/11 " mpolacek at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-07-19 17:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105634

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |---
             Status|RESOLVED                    |REOPENED

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I will actually backport to 12; this problem showed up in Fedora.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/105634] [9/10/11/12 Regression] ICE: Floating point exception in maybe_warn_class_memaccess
  2022-05-17 18:46 [Bug c++/105634] New: ICE: Floating point exception in maybe_warn_class_memaccess gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2022-07-19 17:13 ` mpolacek at gcc dot gnu.org
@ 2022-07-19 18:25 ` cvs-commit at gcc dot gnu.org
  2022-07-19 18:26 ` [Bug c++/105634] [9/10/11 " mpolacek at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-19 18:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105634

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

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

commit r12-8585-gdeafa40eb57b39626e116ca6a15d34a34c57c9f6
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Jul 19 14:24:25 2022 -0400

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

    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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/105634] [9/10/11 Regression] ICE: Floating point exception in maybe_warn_class_memaccess
  2022-05-17 18:46 [Bug c++/105634] New: ICE: Floating point exception in maybe_warn_class_memaccess gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2022-07-19 18:25 ` cvs-commit at gcc dot gnu.org
@ 2022-07-19 18:26 ` mpolacek at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-07-19 18:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105634

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/10/11/12 Regression]     |[9/10/11 Regression] ICE:
                   |ICE: Floating point         |Floating point exception in
                   |exception in                |maybe_warn_class_memaccess
                   |maybe_warn_class_memaccess  |
         Resolution|---                         |FIXED
             Status|REOPENED                    |RESOLVED

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed for GCC 12.2 as well.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-07-19 18:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17 18:46 [Bug c++/105634] New: ICE: Floating point exception in maybe_warn_class_memaccess gscfq@t-online.de
2022-05-17 19:01 ` [Bug c++/105634] [9/10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
2022-05-17 19:05 ` mpolacek at gcc dot gnu.org
2022-05-18 14:33 ` cvs-commit at gcc dot gnu.org
2022-05-18 14:36 ` [Bug c++/105634] [9/10/11/12 " mpolacek at gcc dot gnu.org
2022-07-19 17:13 ` mpolacek at gcc dot gnu.org
2022-07-19 18:25 ` cvs-commit at gcc dot gnu.org
2022-07-19 18:26 ` [Bug c++/105634] [9/10/11 " mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).