public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107593] New: ice with -Wduplicated-cond
@ 2022-11-09 16:48 dcb314 at hotmail dot com
2022-11-09 19:53 ` [Bug c++/107593] [12/13 Regression] " mpolacek at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: dcb314 at hotmail dot com @ 2022-11-09 16:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107593
Bug ID: 107593
Summary: ice with -Wduplicated-cond
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: dcb314 at hotmail dot com
Target Milestone: ---
This C++ code:
template <typename T> void SaturatingCast() {
if (T() && T() && int())
;
else if (T() && T() && int())
;
}
when compiled with recent gcc trunk and flag -Wduplicated-cond:
$ ~/gcc/results/bin/g++ -c -Wduplicated-cond bug860.cc
bug860.cc: In function ‘void SaturatingCast()’:
bug860.cc:4:31: internal compiler error: Segmentation fault
4 | else if (T() && T() && int())
| ^
0x106b5d9 crash_signal(int)
../../trunk.d1/gcc/toplev.cc:314
0x6f9f54 location_wrapper_p(tree_node const*)
../../trunk.d1/gcc/tree.h:4235
0x6f9f54 tree_strip_any_location_wrapper(tree_node*)
../../trunk.d1/gcc/tree.h:4247
I don't have a git hash range for this bug. It seems to have existed for at
least a few weeks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/107593] [12/13 Regression] ice with -Wduplicated-cond
2022-11-09 16:48 [Bug c++/107593] New: ice with -Wduplicated-cond dcb314 at hotmail dot com
@ 2022-11-09 19:53 ` mpolacek at gcc dot gnu.org
2023-01-31 16:37 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-11-09 19:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107593
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.3
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2022-11-09
Ever confirmed|0 |1
CC| |mpolacek at gcc dot gnu.org
Summary|ice with -Wduplicated-cond |[12/13 Regression] ice with
| |-Wduplicated-cond
Priority|P3 |P2
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r12-6022-gbb2a7f80a98de3:
commit bb2a7f80a98de3febefbb32b1e4898062bdb6af8
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Dec 16 13:40:42 2021 -0500
c++: two-stage name lookup for overloaded operators [PR51577]
but it's -Wduplicated-cond so probably mine.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/107593] [12/13 Regression] ice with -Wduplicated-cond
2022-11-09 16:48 [Bug c++/107593] New: ice with -Wduplicated-cond dcb314 at hotmail dot com
2022-11-09 19:53 ` [Bug c++/107593] [12/13 Regression] " 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
3 siblings, 0 replies; 5+ 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=107593
--- Comment #2 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] 5+ messages in thread
* [Bug c++/107593] [12/13 Regression] ice with -Wduplicated-cond
2022-11-09 16:48 [Bug c++/107593] New: ice with -Wduplicated-cond dcb314 at hotmail dot com
2022-11-09 19:53 ` [Bug c++/107593] [12/13 Regression] " 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
3 siblings, 0 replies; 5+ 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=107593
--- Comment #3 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] 5+ messages in thread
* [Bug c++/107593] [12/13 Regression] ice with -Wduplicated-cond
2022-11-09 16:48 [Bug c++/107593] New: ice with -Wduplicated-cond dcb314 at hotmail dot com
` (2 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
3 siblings, 0 replies; 5+ 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=107593
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-31 16:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09 16:48 [Bug c++/107593] New: ice with -Wduplicated-cond dcb314 at hotmail dot com
2022-11-09 19:53 ` [Bug c++/107593] [12/13 Regression] " 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).