[Bug c++/108597] [11/12/13 Regression] internal compiler error with -Wduplicated-cond
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108597 --- Comment #5 from CVS Commits --- The releases/gcc-12 branch has been updated by Marek Polacek : https://gcc.gnu.org/g:07ef737cf1ab08f5c36786c7ab1ffc596fe52138 commit r12-9093-g07ef737cf1ab08f5c36786c7ab1ffc596fe52138 Author: Marek Polacek 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.
[Bug c++/108597] [11/12/13 Regression] internal compiler error with -Wduplicated-cond
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108597 Marek Polacek changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #6 from Marek Polacek --- Fixed.
[Bug c++/108597] [11/12/13 Regression] internal compiler error with -Wduplicated-cond
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108597 --- Comment #4 from CVS Commits --- The trunk branch has been updated by Marek Polacek : https://gcc.gnu.org/g:623730d954a051941ae6a098f851bef308916ca0 commit r13-5582-g623730d954a051941ae6a098f851bef308916ca0 Author: Marek Polacek 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.
[Bug c++/108597] [11/12/13 Regression] internal compiler error with -Wduplicated-cond
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108597 Marek Polacek 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 --- That must be a dup of 107593 but I'll add the test.
[Bug c++/108597] [11/12/13 Regression] internal compiler error with -Wduplicated-cond
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108597 Andrew Pinski 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 --- Confirmed.