public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113340] New: ICE when an explicit object parameter is attempted to be used in a destructor
@ 2024-01-11 20:55 friedkeenan at protonmail dot com
2024-01-11 21:08 ` [Bug c++/113340] " mpolacek at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: friedkeenan at protonmail dot com @ 2024-01-11 20:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113340
Bug ID: 113340
Summary: ICE when an explicit object parameter is attempted to
be used in a destructor
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: friedkeenan at protonmail dot com
Target Milestone: ---
GCC segfaults on the following code:
struct S {
~S(this S &) = default;
};
Godbolt link: https://godbolt.org/z/G6rq3ra6W
It should be noted that explicit object parameters are not allowed for
destructors in the first place, but nonetheless an ICE should not occur when it
is attempted.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/113340] ICE when an explicit object parameter is attempted to be used in a destructor
2024-01-11 20:55 [Bug c++/113340] New: ICE when an explicit object parameter is attempted to be used in a destructor friedkeenan at protonmail dot com
@ 2024-01-11 21:08 ` mpolacek at gcc dot gnu.org
2024-01-11 21:45 ` mpolacek at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-11 21:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113340
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-invalid-code
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
CC| |mpolacek at gcc dot gnu.org
Last reconfirmed| |2024-01-11
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/113340] ICE when an explicit object parameter is attempted to be used in a destructor
2024-01-11 20:55 [Bug c++/113340] New: ICE when an explicit object parameter is attempted to be used in a destructor friedkeenan at protonmail dot com
2024-01-11 21:08 ` [Bug c++/113340] " mpolacek at gcc dot gnu.org
@ 2024-01-11 21:45 ` mpolacek at gcc dot gnu.org
2024-01-15 15:57 ` [Bug c++/113340] [14 Regression] " mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-11 21:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113340
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I suppose the following would be one way to fix it:
--- a/gcc/cp/decl2.cc
+++ b/gcc/cp/decl2.cc
@@ -312,6 +312,12 @@ maybe_retrofit_in_chrg (tree fn)
basetype = TREE_TYPE (TREE_VALUE (arg_types));
arg_types = TREE_CHAIN (arg_types);
+ if (!DECL_ARGUMENTS (fn))
+ {
+ gcc_checking_assert (seen_error ());
+ return;
+ }
+
parms = DECL_CHAIN (DECL_ARGUMENTS (fn));
/* If this is a subobject constructor or destructor, our caller will
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/113340] [14 Regression] ICE when an explicit object parameter is attempted to be used in a destructor
2024-01-11 20:55 [Bug c++/113340] New: ICE when an explicit object parameter is attempted to be used in a destructor friedkeenan at protonmail dot com
2024-01-11 21:08 ` [Bug c++/113340] " mpolacek at gcc dot gnu.org
2024-01-11 21:45 ` mpolacek at gcc dot gnu.org
@ 2024-01-15 15:57 ` mpolacek at gcc dot gnu.org
2024-01-16 22:06 ` cvs-commit at gcc dot gnu.org
2024-01-16 22:11 ` mpolacek at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-15 15:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113340
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|ICE when an explicit object |[14 Regression] ICE when an
|parameter is attempted to |explicit object parameter
|be used in a destructor |is attempted to be used in
| |a destructor
Target Milestone|--- |14.0
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Status|NEW |ASSIGNED
Priority|P3 |P2
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Might be better to leave the 'this' after issuing an error so that the rest of
the code doesn't have to cope.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/113340] [14 Regression] ICE when an explicit object parameter is attempted to be used in a destructor
2024-01-11 20:55 [Bug c++/113340] New: ICE when an explicit object parameter is attempted to be used in a destructor friedkeenan at protonmail dot com
` (2 preceding siblings ...)
2024-01-15 15:57 ` [Bug c++/113340] [14 Regression] " mpolacek at gcc dot gnu.org
@ 2024-01-16 22:06 ` cvs-commit at gcc dot gnu.org
2024-01-16 22:11 ` mpolacek at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-16 22:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113340
--- Comment #4 from GCC 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:ac219d524ace47eea5bf5404b267e22950f44030
commit r14-8165-gac219d524ace47eea5bf5404b267e22950f44030
Author: Marek Polacek <polacek@redhat.com>
Date: Tue Jan 16 15:49:46 2024 -0500
c++: fix ICE with xobj in destructor [PR113340]
Here we crash in maybe_retrofit_in_chrg on an invalid dtor
with explicit this. Such member functions do not get converted
to METHOD_TYPE. If a dtor gets parameters, we reset arg_types
to void_list_node in grokdeclarator. This results in m_r_in_c
receiving:
void <T8d> (void)
and crashing on
parms = DECL_CHAIN (DECL_ARGUMENTS (fn));
This patch avoids the ICE by resetting is_xobj_member_function after
emitting the error. Then m_r_in_c gets
void S::<T40b> (struct S *)
which does not cause a crash.
PR c++/113340
gcc/cp/ChangeLog:
* decl.cc (grokdeclarator) <case cdk_function>: Clear
is_xobj_member_function in case of an error.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/explicit-obj-diagnostics9.C: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/113340] [14 Regression] ICE when an explicit object parameter is attempted to be used in a destructor
2024-01-11 20:55 [Bug c++/113340] New: ICE when an explicit object parameter is attempted to be used in a destructor friedkeenan at protonmail dot com
` (3 preceding siblings ...)
2024-01-16 22:06 ` cvs-commit at gcc dot gnu.org
@ 2024-01-16 22:11 ` mpolacek at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-16 22:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113340
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-01-16 22:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-11 20:55 [Bug c++/113340] New: ICE when an explicit object parameter is attempted to be used in a destructor friedkeenan at protonmail dot com
2024-01-11 21:08 ` [Bug c++/113340] " mpolacek at gcc dot gnu.org
2024-01-11 21:45 ` mpolacek at gcc dot gnu.org
2024-01-15 15:57 ` [Bug c++/113340] [14 Regression] " mpolacek at gcc dot gnu.org
2024-01-16 22:06 ` cvs-commit at gcc dot gnu.org
2024-01-16 22: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).