public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96533] New: ICE with -Wunused-parameter when using three-way comparison
@ 2020-08-08 2:29 natattak at gmail dot com
2020-08-09 15:16 ` [Bug c++/96533] " natattak at gmail dot com
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: natattak at gmail dot com @ 2020-08-08 2:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96533
Bug ID: 96533
Summary: ICE with -Wunused-parameter when using three-way
comparison
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: natattak at gmail dot com
Target Milestone: ---
Minimal example:
#include <compare>
#include <functional>
struct S {
// making it a member fixes the issue
friend auto operator<=>(S, S) = default;
};
// removing 'rhs' fixes the issue
template <typename Lhs, typename Rhs>
auto operator<(Lhs&&, Rhs&& rhs) {
return true;
}
int main() {
// using operator< directly fixes the issue
//return S{} < S{};
return std::less{}(S{}, S{});
}
Compiled with `g++ -std=c++20 -Wunused-parameter`. Output:
'
Internal compiler error: Error reporting routines re-entered.
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
First noticed on g++ 10.1, tested on compiler explorer with current trunk:
https://godbolt.org/z/85j8TW
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/96533] ICE with -Wunused-parameter when using three-way comparison
2020-08-08 2:29 [Bug c++/96533] New: ICE with -Wunused-parameter when using three-way comparison natattak at gmail dot com
@ 2020-08-09 15:16 ` natattak at gmail dot com
2020-08-09 15:19 ` [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload natattak at gmail dot com
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: natattak at gmail dot com @ 2020-08-09 15:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96533
--- Comment #1 from Nathaniel Shead <natattak at gmail dot com> ---
On further investigation, I suspect this is more general than just
`-Wunused-parameter`; the error looks to be caused by any error occurring
within `operator<`. For example,
#include <compare>
#include <functional>
struct S {};
auto operator<=>(S, S) = default;
template <typename Lhs, typename Rhs>
auto operator<(Lhs&&, Rhs&& rhs) {
return rhs.nonexistent;
}
int main() {
return std::less{}(S{}, S{});
}
produces the same issue.
I also discovered that the issue is only when the templated `operator<` has
deduced type.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload
2020-08-08 2:29 [Bug c++/96533] New: ICE with -Wunused-parameter when using three-way comparison natattak at gmail dot com
2020-08-09 15:16 ` [Bug c++/96533] " natattak at gmail dot com
@ 2020-08-09 15:19 ` natattak at gmail dot com
2021-12-16 12:39 ` [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload and -Wunused-parameter pinskia at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: natattak at gmail dot com @ 2020-08-09 15:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96533
Nathaniel Shead <natattak at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|ICE with -Wunused-parameter |ICE with three-way
|when using three-way |comparison when error
|comparison |occurs in templated
| |operator< overload
--- Comment #2 from Nathaniel Shead <natattak at gmail dot com> ---
(Correction with my previous comment, apologies; should be
struct S {};
auto operator<=>(S, S) { return std::strong_ordering::equal; }
— see https://godbolt.org/z/aPxv8d, or otherwise a friend as in my first post.)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload and -Wunused-parameter
2020-08-08 2:29 [Bug c++/96533] New: ICE with -Wunused-parameter when using three-way comparison natattak at gmail dot com
2020-08-09 15:16 ` [Bug c++/96533] " natattak at gmail dot com
2020-08-09 15:19 ` [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload natattak at gmail dot com
@ 2021-12-16 12:39 ` pinskia at gcc dot gnu.org
2021-12-16 14:25 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-16 12:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96533
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reducing ....
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload and -Wunused-parameter
2020-08-08 2:29 [Bug c++/96533] New: ICE with -Wunused-parameter when using three-way comparison natattak at gmail dot com
` (2 preceding siblings ...)
2021-12-16 12:39 ` [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload and -Wunused-parameter pinskia at gcc dot gnu.org
@ 2021-12-16 14:25 ` pinskia at gcc dot gnu.org
2021-12-16 14:28 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-16 14:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96533
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 52014
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52014&action=edit
Reduced as I can get it right now
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload and -Wunused-parameter
2020-08-08 2:29 [Bug c++/96533] New: ICE with -Wunused-parameter when using three-way comparison natattak at gmail dot com
` (3 preceding siblings ...)
2021-12-16 14:25 ` pinskia at gcc dot gnu.org
@ 2021-12-16 14:28 ` pinskia at gcc dot gnu.org
2021-12-16 14:44 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-16 14:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96533
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work|12.0 |
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I can only figure out that it has something to do with __ptr_cmp template
class.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload and -Wunused-parameter
2020-08-08 2:29 [Bug c++/96533] New: ICE with -Wunused-parameter when using three-way comparison natattak at gmail dot com
` (4 preceding siblings ...)
2021-12-16 14:28 ` pinskia at gcc dot gnu.org
@ 2021-12-16 14:44 ` pinskia at gcc dot gnu.org
2021-12-16 14:53 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-16 14:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96533
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #52014|0 |1
is obsolete| |
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 52015
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52015&action=edit
A little smaller
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload and -Wunused-parameter
2020-08-08 2:29 [Bug c++/96533] New: ICE with -Wunused-parameter when using three-way comparison natattak at gmail dot com
` (5 preceding siblings ...)
2021-12-16 14:44 ` pinskia at gcc dot gnu.org
@ 2021-12-16 14:53 ` pinskia at gcc dot gnu.org
2021-12-16 14:54 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-16 14:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96533
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #52015|0 |1
is obsolete| |
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 52016
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52016&action=edit
A little more
The main thing is __not_overloaded and the other operator< really.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload and -Wunused-parameter
2020-08-08 2:29 [Bug c++/96533] New: ICE with -Wunused-parameter when using three-way comparison natattak at gmail dot com
` (6 preceding siblings ...)
2021-12-16 14:53 ` pinskia at gcc dot gnu.org
@ 2021-12-16 14:54 ` pinskia at gcc dot gnu.org
2021-12-16 15:10 ` mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-16 14:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96533
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
0xccadfb do_warn_unused_parameter(tree_node*)
/home/apinski/src/upstream-gcc/gcc/gcc/c-family/c-warn.c:2414
0xa74de1 finish_function(bool)
/home/apinski/src/upstream-gcc/gcc/gcc/cp/decl.c:17816
0xba9b36 instantiate_body
/home/apinski/src/upstream-gcc/gcc/gcc/cp/pt.c:26176
0xbaad6a instantiate_decl(tree_node*, bool, bool)
/home/apinski/src/upstream-gcc/gcc/gcc/cp/pt.c:26450
0xa8586a maybe_instantiate_decl(tree_node*)
/home/apinski/src/upstream-gcc/gcc/gcc/cp/decl2.c:5594
0xa86aac maybe_instantiate_decl(tree_node*)
/home/apinski/src/upstream-gcc/gcc/gcc/cp/decl2.c:5830
0xa86aac mark_used(tree_node*, int)
/home/apinski/src/upstream-gcc/gcc/gcc/cp/decl2.c:5856
0x9ce2ce build_over_call
/home/apinski/src/upstream-gcc/gcc/gcc/cp/call.c:9819
0x9d4f59 build_new_op(op_location_t const&, tree_code, int, tree_node*,
tree_node*, tree_node*, tree_node**, int)
/home/apinski/src/upstream-gcc/gcc/gcc/cp/call.c:6685
0x9d5296 build_new_op(op_location_t const&, tree_code, int, tree_node*,
tree_node*, tree_node*, tree_node**, int)
/home/apinski/src/upstream-gcc/gcc/gcc/cp/call.c:6768
0xc1ead3 build_x_binary_op(op_location_t const&, tree_code, tree_node*,
tree_code, tree_node*, tree_code, tree_node**, int)
/home/apinski/src/upstream-gcc/gcc/gcc/cp/typeck.c:4480
0xb95898 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
/home/apinski/src/upstream-gcc/gcc/gcc/cp/pt.c:20074
0xba60ce tsubst(tree_node*, tree_node*, int, tree_node*)
/home/apinski/src/upstream-gcc/gcc/gcc/cp/pt.c:16181
0xa97631 dump_template_bindings
/home/apinski/src/upstream-gcc/gcc/gcc/cp/error.c:486
0xa90a8a dump_function_decl
/home/apinski/src/upstream-gcc/gcc/gcc/cp/error.c:1806
0xa98dc4 decl_to_string
/home/apinski/src/upstream-gcc/gcc/gcc/cp/error.c:3226
0xa98dc4 cp_printer
/home/apinski/src/upstream-gcc/gcc/gcc/cp/error.c:4397
0x2118a6c pp_format(pretty_printer*, text_info*)
/home/apinski/src/upstream-gcc/gcc/gcc/pretty-print.c:1475
0x211ac00 pp_format_verbatim(pretty_printer*, text_info*)
/home/apinski/src/upstream-gcc/gcc/gcc/pretty-print.c:1536
0x211ac00 pp_verbatim(pretty_printer*, char const*, ...)
/home/apinski/src/upstream-gcc/gcc/gcc/pretty-print.c:1790
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload and -Wunused-parameter
2020-08-08 2:29 [Bug c++/96533] New: ICE with -Wunused-parameter when using three-way comparison natattak at gmail dot com
` (7 preceding siblings ...)
2021-12-16 14:54 ` pinskia at gcc dot gnu.org
@ 2021-12-16 15:10 ` mpolacek at gcc dot gnu.org
2023-07-13 19:06 ` ppalka at gcc dot gnu.org
2023-07-13 20:09 ` ppalka at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-12-16 15:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96533
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-12-16
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
CC| |mpolacek at gcc dot gnu.org
--- Comment #9 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed. do_warn_unused_parameter ends up calling itself, oops.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload and -Wunused-parameter
2020-08-08 2:29 [Bug c++/96533] New: ICE with -Wunused-parameter when using three-way comparison natattak at gmail dot com
` (8 preceding siblings ...)
2021-12-16 15:10 ` mpolacek at gcc dot gnu.org
@ 2023-07-13 19:06 ` ppalka at gcc dot gnu.org
2023-07-13 20:09 ` ppalka at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-07-13 19:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96533
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |12.1.0, 13.1.0
Known to fail| |10.5.0, 11.4.0
CC| |ppalka at gcc dot gnu.org
--- Comment #10 from Patrick Palka <ppalka at gcc dot gnu.org> ---
This seems fixed for GCC 12+ by r12-6022-gbb2a7f80a98de3.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload and -Wunused-parameter
2020-08-08 2:29 [Bug c++/96533] New: ICE with -Wunused-parameter when using three-way comparison natattak at gmail dot com
` (9 preceding siblings ...)
2023-07-13 19:06 ` ppalka at gcc dot gnu.org
@ 2023-07-13 20:09 ` ppalka at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-07-13 20:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96533
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Target Milestone|--- |12.0
Resolution|--- |FIXED
--- Comment #11 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Thus fixed. Adding a testcase for this issue doesn't seem super worthwhile.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-07-13 20:09 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-08 2:29 [Bug c++/96533] New: ICE with -Wunused-parameter when using three-way comparison natattak at gmail dot com
2020-08-09 15:16 ` [Bug c++/96533] " natattak at gmail dot com
2020-08-09 15:19 ` [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload natattak at gmail dot com
2021-12-16 12:39 ` [Bug c++/96533] ICE with three-way comparison when error occurs in templated operator< overload and -Wunused-parameter pinskia at gcc dot gnu.org
2021-12-16 14:25 ` pinskia at gcc dot gnu.org
2021-12-16 14:28 ` pinskia at gcc dot gnu.org
2021-12-16 14:44 ` pinskia at gcc dot gnu.org
2021-12-16 14:53 ` pinskia at gcc dot gnu.org
2021-12-16 14:54 ` pinskia at gcc dot gnu.org
2021-12-16 15:10 ` mpolacek at gcc dot gnu.org
2023-07-13 19:06 ` ppalka at gcc dot gnu.org
2023-07-13 20:09 ` ppalka 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).