public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108597] New: internal compiler error with -Wduplicated-cond
@ 2023-01-30 12:11 mserdarsanli at gmail dot com
  2023-01-30 12:15 ` [Bug c++/108597] " mserdarsanli at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: mserdarsanli at gmail dot com @ 2023-01-30 12:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108597
           Summary: internal compiler error with -Wduplicated-cond
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mserdarsanli at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/Kdvd5hzYK

compile below with -Wduplicated-cond and it will crash

template <typename T>
struct MyStruct {

    void check(int &x) {
        if (&x == &_a) {
        } else if (&x == &_b) {
        }
    }

    int _a;
    int _b;
};

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

* [Bug c++/108597] internal compiler error with -Wduplicated-cond
  2023-01-30 12:11 [Bug c++/108597] New: internal compiler error with -Wduplicated-cond mserdarsanli at gmail dot com
@ 2023-01-30 12:15 ` mserdarsanli at gmail dot com
  2023-01-30 12:44 ` [Bug c++/108597] [11/12/13 Regression] " pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mserdarsanli at gmail dot com @ 2023-01-30 12:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Serdar Sanli <mserdarsanli at gmail dot com> ---
stacktrace from my gcc 12.2.0:

0xe2534f crash_signal
        /root/source/gcc-12.2.0/gcc/toplev.cc:322
0xb0f049 location_wrapper_p(tree_node const*)
        /root/source/gcc-12.2.0/gcc/tree.h:4160
0xb0f049 tree_strip_any_location_wrapper(tree_node*)
        /root/source/gcc-12.2.0/gcc/tree.h:4172
0xb0f049 operand_compare::operand_equal_p(tree_node const*, tree_node const*,
unsigned int)
        /root/source/gcc-12.2.0/gcc/fold-const.cc:2987
0xb100fb operand_compare::operand_equal_p(tree_node const*, tree_node const*,
unsigned int)
        /root/source/gcc-12.2.0/gcc/fold-const.cc:3363                         
                                                                               
                                                   0xb0f3f1
operand_compare::operand_equal_p(tree_node const*, tree_node const*, unsigned
int)
        /root/source/gcc-12.2.0/gcc/fold-const.cc:3227                         
                                                                               
                                                   0x9a6f07
warn_duplicated_cond_add_or_warn(unsigned int, tree_node*, vec<tree_node*,
va_heap, vl_ptr>**)
        /root/source/gcc-12.2.0/gcc/c-family/c-warn.cc:2537
0x894e18 cp_parser_selection_statement
        /root/source/gcc-12.2.0/gcc/cp/parser.cc:13108                         
                                                                               
                                                   0x86f5d5 cp_parser_statement
        /root/source/gcc-12.2.0/gcc/cp/parser.cc:12296                         
                                                                               
                                                   0x893fe1
cp_parser_implicitly_scoped_statement
        /root/source/gcc-12.2.0/gcc/cp/parser.cc:14423
0x895239 cp_parser_selection_statement
        /root/source/gcc-12.2.0/gcc/cp/parser.cc:13186
0x86f5d5 cp_parser_statement
        /root/source/gcc-12.2.0/gcc/cp/parser.cc:12296
0x87016d cp_parser_statement_seq_opt
        /root/source/gcc-12.2.0/gcc/cp/parser.cc:12850
0x87021f cp_parser_compound_statement
        /root/source/gcc-12.2.0/gcc/cp/parser.cc:12802
0x88ec73 cp_parser_function_body
        /root/source/gcc-12.2.0/gcc/cp/parser.cc:25071
0x88ec73 cp_parser_ctor_initializer_opt_and_function_body
        /root/source/gcc-12.2.0/gcc/cp/parser.cc:25122
0x88fdbe cp_parser_function_definition_after_declarator
        /root/source/gcc-12.2.0/gcc/cp/parser.cc:31257
0x8900e3 cp_parser_late_parsing_for_member
        /root/source/gcc-12.2.0/gcc/cp/parser.cc:32189
0x86a06e cp_parser_class_specifier_1
        /root/source/gcc-12.2.0/gcc/cp/parser.cc:26190
0x86af46 cp_parser_class_specifier
        /root/source/gcc-12.2.0/gcc/cp/parser.cc:26214

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

* [Bug c++/108597] [11/12/13 Regression] internal compiler error with -Wduplicated-cond
  2023-01-30 12:11 [Bug c++/108597] New: internal compiler error with -Wduplicated-cond mserdarsanli at gmail dot com
  2023-01-30 12:15 ` [Bug c++/108597] " mserdarsanli at gmail dot com
@ 2023-01-30 12:44 ` pinskia at gcc dot gnu.org
  2023-01-30 14:05 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-30 12:44 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |11.1.0
      Known to work|                            |10.4.0
             Status|UNCONFIRMED                 |NEW
            Summary|internal compiler error     |[11/12/13 Regression]
                   |with -Wduplicated-cond      |internal compiler error
                   |                            |with -Wduplicated-cond
   Target Milestone|---                         |11.4
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-01-30

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/108597] [11/12/13 Regression] internal compiler error with -Wduplicated-cond
  2023-01-30 12:11 [Bug c++/108597] New: internal compiler error with -Wduplicated-cond mserdarsanli at gmail dot com
  2023-01-30 12:15 ` [Bug c++/108597] " mserdarsanli at gmail dot com
  2023-01-30 12:44 ` [Bug c++/108597] [11/12/13 Regression] " pinskia at gcc dot gnu.org
@ 2023-01-30 14:05 ` mpolacek at gcc dot gnu.org
  2023-01-31 16:37 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-01-30 14:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
             Status|NEW                         |ASSIGNED
           Priority|P3                          |P2
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
That must be a dup of 107593 but I'll add the test.

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

* [Bug c++/108597] [11/12/13 Regression] internal compiler error with -Wduplicated-cond
  2023-01-30 12:11 [Bug c++/108597] New: internal compiler error with -Wduplicated-cond mserdarsanli at gmail dot com
                   ` (2 preceding siblings ...)
  2023-01-30 14:05 ` mpolacek at gcc dot gnu.org
@ 2023-01-31 16:37 ` cvs-commit at gcc dot gnu.org
  2023-01-31 16:55 ` cvs-commit at gcc dot gnu.org
  2023-01-31 16:55 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-31 16:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 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:623730d954a051941ae6a098f851bef308916ca0

commit r13-5582-g623730d954a051941ae6a098f851bef308916ca0
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Jan 26 09:34:28 2023 -0500

    c++: fix ICE with -Wduplicated-cond [PR107593]

    Here we crash because a CAST_EXPR, representing T(), doesn't have
    its operand, and operand_equal_p's STRIP_ANY_LOCATION_WRAPPER doesn't
    expect that.  (o_e_p is called from warn_duplicated_cond_add_or_warn.)

    In the past we've adjusted o_e_p to better cope with template codes,
    but in this case I think we just want to avoid attempting to warn
    about inst-dependent expressions; I don't think I've ever envisioned
    -Wduplicated-cond to warn about them.  Also destroy the chain when
    an inst-dependent expression is encountered to not warn in
    Wduplicated-cond4.C.

    The ICE started with r12-6022, two-stage name lookup for overloaded
    operators, which gave dependent operators a TREE_TYPE (in particular,
    DEPENDENT_OPERATOR_TYPE), so we no longer bail out here in o_e_p:

      /* Similar, if either does not have a type (like a template id),
         they aren't equal.  */
      if (!TREE_TYPE (arg0) || !TREE_TYPE (arg1))
        return false;

            PR c++/107593
            PR c++/108597

    gcc/c-family/ChangeLog:

            * c-common.h (instantiation_dependent_expression_p): Declare.
            * c-warn.cc (warn_duplicated_cond_add_or_warn): If the condition
            is dependent, invalidate the chain.

    gcc/c/ChangeLog:

            * c-objc-common.cc (instantiation_dependent_expression_p): New.

    gcc/cp/ChangeLog:

            * cp-tree.h (instantiation_dependent_expression_p): Don't
            declare here.

    gcc/testsuite/ChangeLog:

            * g++.dg/warn/Wduplicated-cond3.C: New test.
            * g++.dg/warn/Wduplicated-cond4.C: New test.
            * g++.dg/warn/Wduplicated-cond5.C: New test.

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

* [Bug c++/108597] [11/12/13 Regression] internal compiler error with -Wduplicated-cond
  2023-01-30 12:11 [Bug c++/108597] New: internal compiler error with -Wduplicated-cond mserdarsanli at gmail dot com
                   ` (3 preceding siblings ...)
  2023-01-31 16:37 ` cvs-commit at gcc dot gnu.org
@ 2023-01-31 16:55 ` cvs-commit at gcc dot gnu.org
  2023-01-31 16:55 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-31 16:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 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:07ef737cf1ab08f5c36786c7ab1ffc596fe52138

commit r12-9093-g07ef737cf1ab08f5c36786c7ab1ffc596fe52138
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Jan 31 11:54:03 2023 -0500

    c++: fix ICE with -Wduplicated-cond [PR107593]

    Here we crash because a CAST_EXPR, representing T(), doesn't have
    its operand, and operand_equal_p's STRIP_ANY_LOCATION_WRAPPER doesn't
    expect that.  (o_e_p is called from warn_duplicated_cond_add_or_warn.)

    In the past we've adjusted o_e_p to better cope with template codes,
    but in this case I think we just want to avoid attempting to warn
    about inst-dependent expressions; I don't think I've ever envisioned
    -Wduplicated-cond to warn about them.  Also destroy the chain when
    an inst-dependent expression is encountered to not warn in
    Wduplicated-cond4.C.

    The ICE started with r12-6022, two-stage name lookup for overloaded
    operators, which gave dependent operators a TREE_TYPE (in particular,
    DEPENDENT_OPERATOR_TYPE), so we no longer bail out here in o_e_p:

      /* Similar, if either does not have a type (like a template id),
         they aren't equal.  */
      if (!TREE_TYPE (arg0) || !TREE_TYPE (arg1))
        return false;

            PR c++/107593
            PR c++/108597

    gcc/c-family/ChangeLog:

            * c-common.h (instantiation_dependent_expression_p): Declare.
            * c-warn.cc (warn_duplicated_cond_add_or_warn): If the condition
            is dependent, invalidate the chain.

    gcc/c/ChangeLog:

            * c-objc-common.cc (instantiation_dependent_expression_p): New.

    gcc/cp/ChangeLog:

            * cp-tree.h (instantiation_dependent_expression_p): Don't
            declare here.

    gcc/testsuite/ChangeLog:

            * g++.dg/warn/Wduplicated-cond3.C: New test.
            * g++.dg/warn/Wduplicated-cond4.C: New test.
            * g++.dg/warn/Wduplicated-cond5.C: New test.

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

* [Bug c++/108597] [11/12/13 Regression] internal compiler error with -Wduplicated-cond
  2023-01-30 12:11 [Bug c++/108597] New: internal compiler error with -Wduplicated-cond mserdarsanli at gmail dot com
                   ` (4 preceding siblings ...)
  2023-01-31 16:55 ` cvs-commit at gcc dot gnu.org
@ 2023-01-31 16:55 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-01-31 16:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2023-01-31 16:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-30 12:11 [Bug c++/108597] New: internal compiler error with -Wduplicated-cond mserdarsanli at gmail dot com
2023-01-30 12:15 ` [Bug c++/108597] " mserdarsanli at gmail dot com
2023-01-30 12:44 ` [Bug c++/108597] [11/12/13 Regression] " pinskia at gcc dot gnu.org
2023-01-30 14:05 ` mpolacek at gcc dot gnu.org
2023-01-31 16:37 ` cvs-commit at gcc dot gnu.org
2023-01-31 16:55 ` cvs-commit at gcc dot gnu.org
2023-01-31 16:55 ` 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).