From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7839D3858404; Thu, 28 Oct 2021 12:49:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7839D3858404 From: "peeceseven at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102987] New: [9, 10, 11, trunk] Segfault when error or warning should trigger with combination. Date: Thu, 28 Oct 2021 12:49:20 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: peeceseven at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Oct 2021 12:49:20 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102987 Bug ID: 102987 Summary: [9,10,11,trunk] Segfault when error or warning should trigger with combination. Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: peeceseven at gmail dot com Target Milestone: --- Created attachment 51690 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D51690&action=3Dedit creduced sample code. I am using GCC 11.1 locally. When I detected the issue, I ran creduce to fi= nd a sample test case. Then I used it on godbolt.org to see what versions were affected. The latest version of GCC I found that didn=E2=80=99t have this i= ssue was 8.5. It seems to me anything you put in function g that should cause an error or warning causes the segfault. Sample 1: This should be erroring because lacking a return value, or warn t= hat this is unused. // begin code // https://godbolt.org/z/3TxGsGbYr struct a { bool b(); }; template struct d : c { c::e; using f =3D d; constexpr f g(decltype(e.b())) { this; } }; struct h { a e; }; using i =3D d; auto j =3D i{}.g(1); // end code // begin error output :6:5: warning: access declarations are deprecated in favour of using-declarations; suggestion: add the 'using' keyword [-Wdeprecated] 6 | c::e; | ^ ' Segmentation fault 8 | constexpr f g(decltype(e.b())) { this; } | ^ 0x2006499 internal_error(char const*, ...) ???:0 0x2022991 pp_format(pretty_printer*, text_info*) ???:0 0x2023010 pp_format_verbatim(pretty_printer*, text_info*) ???:0 0x20230f1 pp_verbatim(pretty_printer*, char const*, ...) ???:0 0x20050d1 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info= *) ???:0 0x2008306 error_at(rich_location*, char const*, ...) ???:0 0x8d2035 finish_function(bool) ???:0 0xa45f47 instantiate_decl(tree_node*, bool, bool) ???:0 0x1501d13 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*)) ???:0 0x150275c walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*)) ???:0 0x1505ef5 walk_tree_without_duplicates_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*)) ???:0 0xb20690 store_init_value(tree_node*, tree_node*, vec**, int) ???:0 0x8d3fa9 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int) ???:0 0xa0c105 c_parse_file() ???:0 0xb93132 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See for instructions. Compiler returned: 1 // end error output Sample 2: This is using -Wunused-but-set-variable. Should be warning on the unused variable set instead of segfault. If we remove the -Wunused-but-set-variable this compiles normally. This is closer to what my actual code. I had two unused variables and I had this warning on. // begin code // https://godbolt.org/z/K4Ma5qbYo struct a { bool b(); }; template struct d : c { using c::e; using f =3D d; constexpr f g(decltype(e.b())) { auto r =3D *this; const auto a =3D r.e; //-Wunused-but-set-variable return r;} }; struct h { a e; }; using i =3D d; auto j =3D i{}.g(1); // end code // begin error output Segmentation fault 11 | return r;} | ^ 0x2006499 internal_error(char const*, ...) ???:0 0x2022991 pp_format(pretty_printer*, text_info*) ???:0 0x2023010 pp_format_verbatim(pretty_printer*, text_info*) ???:0 0x20230f1 pp_verbatim(pretty_printer*, char const*, ...) ???:0 0x20050d1 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info= *) ???:0 0x2005c75 warning_at(unsigned int, int, char const*, ...) ???:0 0x8cf9c2 poplevel(int, int, int) ???:0 0xaa3603 do_poplevel(tree_node*) ???:0 0xaa84f9 finish_compound_stmt(tree_node*) ???:0 0xa45f47 instantiate_decl(tree_node*, bool, bool) ???:0 0x1501d13 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*)) ???:0 0x150275c walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*)) ???:0 0x1505ef5 walk_tree_without_duplicates_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*)) ???:0 0xb20690 store_init_value(tree_node*, tree_node*, vec**, int) ???:0 0x8d3fa9 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int) ???:0 0xa0c105 c_parse_file() ???:0 0xb93132 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See for instructions. Compiler returned: 1 // end error output=