public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug plugins/98062] New: [11 regression] Crash in type_as_string from plugin
@ 2020-11-30 3:40 sss@li-snyder.org
2020-11-30 8:14 ` [Bug plugins/98062] " rguenth at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: sss@li-snyder.org @ 2020-11-30 3:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98062
Bug ID: 98062
Summary: [11 regression] Crash in type_as_string from plugin
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: plugins
Assignee: unassigned at gcc dot gnu.org
Reporter: sss@li-snyder.org
Target Milestone: ---
hi -
A plugin i'm working on crashes with gcc 11 because
pp_cxx_trait_expression doesn't handle the CPTK_IS_NOTHROW_CONSTRUCTIBLE enum.
Here's a simple reproducer. First, here's the plugin:
-- p.cc ---------------------------------------------------
#include "gcc-plugin.h"
#include "cp/cp-tree.h"
int plugin_is_GPL_compatible;
void type_callback (void* gcc_data, void*)
{
tree t = (tree)gcc_data;
tree binfo = TYPE_BINFO (t);
if (binfo && BINFO_N_BASE_BINFOS (binfo) > 0) {
tree base_binfo = BINFO_BASE_BINFO (binfo, 0);
tree bt = BINFO_TYPE (base_binfo);
if (bt) {
type_as_string (bt, 0);
}
}
}
extern "C" {
int
plugin_init(struct plugin_name_args *, struct plugin_gcc_version *)
{
register_callback ("a", PLUGIN_FINISH_TYPE, type_callback, nullptr);
return 0;
}
} // extern "C"
-----------------------------------------------------------------------
Compile with
$ g++ -fPIC -shared -o libp.so p.cc -I`g++ -print-file-name=plugin`/include
Run it with this input:
-- x.cc ------------------------------------------------------------------
template <bool v> class B {};
template<typename _Tp>
struct is_nothrow_default_constructible
: public B<__is_nothrow_constructible(_Tp)>
{
};
--------------------------------------------------------------------------
$ g++ -fplugin=libp.so -c x.cc
*** WARNING *** there are active plugins, do not report this as a bug unless
you can reproduce it without enabling any plugins.
Event | Plugins
PLUGIN_FINISH_TYPE | a
x.cc:7:1: internal compiler error: in pp_cxx_trait_expression, at
cp/cxx-pretty-print.c:2671
7 | };
| ^
0x61483f pp_cxx_trait_expression(cxx_pretty_printer*, tree_node*)
/home/sss/gcc/gcc/gcc/cp/cxx-pretty-print.c:2671
0x6e82ef dump_template_parms
/home/sss/gcc/gcc/gcc/cp/error.c:1945
0x6ec3dc type_as_string(tree_node*, int)
/home/sss/gcc/gcc/gcc/cp/error.c:3024
0xbd60c9 invoke_plugin_callbacks_full(int, void*)
/home/sss/gcc/gcc/gcc/plugin.c:588
0x73ed8f invoke_plugin_callbacks
/home/sss/gcc/gcc/gcc/plugin.h:191
0x73ed8f cp_parser_type_specifier
/home/sss/gcc/gcc/gcc/cp/parser.c:17964
0x73f7fb cp_parser_decl_specifier_seq
/home/sss/gcc/gcc/gcc/cp/parser.c:14585
0x766536 cp_parser_single_declaration
/home/sss/gcc/gcc/gcc/cp/parser.c:29908
0x766897 cp_parser_template_declaration_after_parameters
/home/sss/gcc/gcc/gcc/cp/parser.c:29571
0x766e9a cp_parser_explicit_template_declaration
/home/sss/gcc/gcc/gcc/cp/parser.c:29837
0x7697d9 cp_parser_declaration
/home/sss/gcc/gcc/gcc/cp/parser.c:13609
0x76a04d cp_parser_translation_unit
/home/sss/gcc/gcc/gcc/cp/parser.c:4806
0x76a04d c_parse_file()
/home/sss/gcc/gcc/gcc/cp/parser.c:44630
0x837bed c_common_parse_file()
/home/sss/gcc/gcc/gcc/c-family/c-opts.c:1198
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.
This patch fixes the crash:
diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
index 058b9c2f4fc..b1e10f9e2a8 100644
--- a/gcc/cp/cxx-pretty-print.c
+++ b/gcc/cp/cxx-pretty-print.c
@@ -2666,6 +2666,9 @@ pp_cxx_trait_expression (cxx_pretty_printer *pp, tree t)
case CPTK_IS_CONSTRUCTIBLE:
pp_cxx_ws_string (pp, "__is_constructible");
break;
+ case CPTK_IS_NOTHROW_CONSTRUCTIBLE:
+ pp_cxx_ws_string (pp, "__is_nothrow_constructible");
+ break;
default:
gcc_unreachable ();
However, there are still a few other CPTK_ enums that aren't handled
in pp_cxx_trait_expression --- probably PTK_IS_NOTHROW_ASSIGNABLE
should be there, at least.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug plugins/98062] [11 regression] Crash in type_as_string from plugin
2020-11-30 3:40 [Bug plugins/98062] New: [11 regression] Crash in type_as_string from plugin sss@li-snyder.org
@ 2020-11-30 8:14 ` rguenth at gcc dot gnu.org
2021-01-14 10:58 ` [Bug c++/98062] " rguenth at gcc dot gnu.org
2021-01-15 19:49 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-11-30 8:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98062
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/98062] [11 regression] Crash in type_as_string from plugin
2020-11-30 3:40 [Bug plugins/98062] New: [11 regression] Crash in type_as_string from plugin sss@li-snyder.org
2020-11-30 8:14 ` [Bug plugins/98062] " rguenth at gcc dot gnu.org
@ 2021-01-14 10:58 ` rguenth at gcc dot gnu.org
2021-01-15 19:49 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-14 10:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98062
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|plugins |c++
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Patches should be sent to gcc-patches@gcc.gnu.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/98062] [11 regression] Crash in type_as_string from plugin
2020-11-30 3:40 [Bug plugins/98062] New: [11 regression] Crash in type_as_string from plugin sss@li-snyder.org
2020-11-30 8:14 ` [Bug plugins/98062] " rguenth at gcc dot gnu.org
2021-01-14 10:58 ` [Bug c++/98062] " rguenth at gcc dot gnu.org
@ 2021-01-15 19:49 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-01-15 19:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98062
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
CC| |mpolacek at gcc dot gnu.org
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Most likely got resolved by r11-5629.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-01-15 19:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-30 3:40 [Bug plugins/98062] New: [11 regression] Crash in type_as_string from plugin sss@li-snyder.org
2020-11-30 8:14 ` [Bug plugins/98062] " rguenth at gcc dot gnu.org
2021-01-14 10:58 ` [Bug c++/98062] " rguenth at gcc dot gnu.org
2021-01-15 19:49 ` 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).