public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102987] New: [9, 10, 11, trunk] Segfault when error or warning should trigger with combination.
@ 2021-10-28 12:49 peeceseven at gmail dot com
  2021-10-28 12:50 ` [Bug c++/102987] [9,10,11,trunk] " peeceseven at gmail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: peeceseven at gmail dot com @ 2021-10-28 12:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102987

            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=51690&action=edit
creduced sample code.

I am using GCC 11.1 locally. When I detected the issue, I ran creduce to find 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’t have this issue 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 that
this is unused.
// begin code
// https://godbolt.org/z/3TxGsGbYr
struct a {
  bool b();
};
template <typename c> struct d : c {
  c::e;
  using f = d;
  constexpr f g(decltype(e.b())) { this; }
};
struct h {
  a e;
};
using i = d<h>;
auto j = i{}.g(1);
// end code
// begin error output
<source>: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*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???:0
0x150275c walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???: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<tree_node*, false,
default_hash_traits<tree_node*> >*))
        ???:0
0xb20690 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, 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 <https://gcc.gnu.org/bugs/> 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 <typename c>
struct d : c {
  using c::e;
  using f = d;
  constexpr f g(decltype(e.b())) {
    auto r = *this;
    const auto a = r.e; //-Wunused-but-set-variable
    return r;}
};
struct h {
  a e;
};
using i = d<h>;
auto j = 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*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???:0
0x150275c walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        ???: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<tree_node*, false,
default_hash_traits<tree_node*> >*))
        ???:0
0xb20690 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, 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 <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
// end error output

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/102987] [9,10,11,trunk] Segfault when error or warning should trigger with combination.
  2021-10-28 12:49 [Bug c++/102987] New: [9, 10, 11, trunk] Segfault when error or warning should trigger with combination peeceseven at gmail dot com
@ 2021-10-28 12:50 ` peeceseven at gmail dot com
  2021-10-28 12:52 ` peeceseven at gmail dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: peeceseven at gmail dot com @ 2021-10-28 12:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102987

--- Comment #1 from Robert Russell <peeceseven at gmail dot com> ---
Created attachment 51691
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51691&action=edit
adjusted previous sample closer to my use case.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/102987] [9,10,11,trunk] Segfault when error or warning should trigger with combination.
  2021-10-28 12:49 [Bug c++/102987] New: [9, 10, 11, trunk] Segfault when error or warning should trigger with combination peeceseven at gmail dot com
  2021-10-28 12:50 ` [Bug c++/102987] [9,10,11,trunk] " peeceseven at gmail dot com
@ 2021-10-28 12:52 ` peeceseven at gmail dot com
  2021-10-29  6:38 ` [Bug c++/102987] [9/10/11/12 Regression] " rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: peeceseven at gmail dot com @ 2021-10-28 12:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102987

--- Comment #2 from Robert Russell <peeceseven at gmail dot com> ---
Created attachment 51692
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51692&action=edit
this is the build script i was using with creduce. probably not needed

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/102987] [9/10/11/12 Regression] Segfault when error or warning should trigger with combination.
  2021-10-28 12:49 [Bug c++/102987] New: [9, 10, 11, trunk] Segfault when error or warning should trigger with combination peeceseven at gmail dot com
  2021-10-28 12:50 ` [Bug c++/102987] [9,10,11,trunk] " peeceseven at gmail dot com
  2021-10-28 12:52 ` peeceseven at gmail dot com
@ 2021-10-29  6:38 ` rguenth at gcc dot gnu.org
  2022-04-14 21:39 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-29  6:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102987

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9,10,11,trunk] Segfault    |[9/10/11/12 Regression]
                   |when error or warning       |Segfault when error or
                   |should trigger with         |warning should trigger with
                   |combination.                |combination.
   Target Milestone|---                         |9.5
           Keywords|                            |diagnostic,
                   |                            |ice-on-valid-code
           Priority|P3                          |P2
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |8.5.0
   Last reconfirmed|                            |2021-10-29
     Ever confirmed|0                           |1

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  We have a VIEW_CONVERT_EXPR with NULL TREE_TYPE when dumping a
TEMPLATE_DECL.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/102987] [9/10/11/12 Regression] Segfault when error or warning should trigger with combination.
  2021-10-28 12:49 [Bug c++/102987] New: [9, 10, 11, trunk] Segfault when error or warning should trigger with combination peeceseven at gmail dot com
                   ` (2 preceding siblings ...)
  2021-10-29  6:38 ` [Bug c++/102987] [9/10/11/12 Regression] " rguenth at gcc dot gnu.org
@ 2022-04-14 21:39 ` jason at gcc dot gnu.org
  2022-04-15  1:00 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2022-04-14 21:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102987

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/102987] [9/10/11/12 Regression] Segfault when error or warning should trigger with combination.
  2021-10-28 12:49 [Bug c++/102987] New: [9, 10, 11, trunk] Segfault when error or warning should trigger with combination peeceseven at gmail dot com
                   ` (3 preceding siblings ...)
  2022-04-14 21:39 ` jason at gcc dot gnu.org
@ 2022-04-15  1:00 ` cvs-commit at gcc dot gnu.org
  2022-04-29 13:21 ` [Bug c++/102987] [9/10/11 " cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-15  1:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102987

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:6364a39907bd68624a30df0c8e380c40d2a646c4

commit r12-8172-g6364a39907bd68624a30df0c8e380c40d2a646c4
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Apr 14 17:35:35 2022 -0400

    c++: using in diagnostics [PR102987]

    The expression pretty-printing code crashed on a location wrapper with no
    type, and didn't know what to do with a USING_DECL.

            PR c++/102987

    gcc/cp/ChangeLog:

            * error.cc (dump_expr): Handle USING_DECL.
            [VIEW_CONVERT_EXPR]: Just look through location wrapper.

    gcc/testsuite/ChangeLog:

            * g++.dg/diagnostic/using1.C: New test.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/102987] [9/10/11 Regression] Segfault when error or warning should trigger with combination.
  2021-10-28 12:49 [Bug c++/102987] New: [9, 10, 11, trunk] Segfault when error or warning should trigger with combination peeceseven at gmail dot com
                   ` (4 preceding siblings ...)
  2022-04-15  1:00 ` cvs-commit at gcc dot gnu.org
@ 2022-04-29 13:21 ` cvs-commit at gcc dot gnu.org
  2022-05-27  9:46 ` [Bug c++/102987] [10/11 " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-29 13:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102987

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:a0a2554d7c86c126de85fcbd5bd7e16dbb5a2693

commit r13-42-ga0a2554d7c86c126de85fcbd5bd7e16dbb5a2693
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Apr 14 17:35:35 2022 -0400

    c++: using in diagnostics [PR102987]

    The decl pretty-printing code wasn't looking at the flags parameter, so we
    were printing 'using' in the middle of an expression.

            PR c++/102987

    gcc/cp/ChangeLog:

            * error.cc (dump_decl) [USING_DECL]: Respect flags.

    gcc/testsuite/ChangeLog:

            * g++.dg/diagnostic/using1.C: Check pretty-printing.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/102987] [10/11 Regression] Segfault when error or warning should trigger with combination.
  2021-10-28 12:49 [Bug c++/102987] New: [9, 10, 11, trunk] Segfault when error or warning should trigger with combination peeceseven at gmail dot com
                   ` (5 preceding siblings ...)
  2022-04-29 13:21 ` [Bug c++/102987] [9/10/11 " cvs-commit at gcc dot gnu.org
@ 2022-05-27  9:46 ` rguenth at gcc dot gnu.org
  2022-06-28 10:46 ` jakub at gcc dot gnu.org
  2023-07-07 10:41 ` [Bug c++/102987] [11 " rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102987

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |10.4

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/102987] [10/11 Regression] Segfault when error or warning should trigger with combination.
  2021-10-28 12:49 [Bug c++/102987] New: [9, 10, 11, trunk] Segfault when error or warning should trigger with combination peeceseven at gmail dot com
                   ` (6 preceding siblings ...)
  2022-05-27  9:46 ` [Bug c++/102987] [10/11 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:46 ` jakub at gcc dot gnu.org
  2023-07-07 10:41 ` [Bug c++/102987] [11 " rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102987

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/102987] [11 Regression] Segfault when error or warning should trigger with combination.
  2021-10-28 12:49 [Bug c++/102987] New: [9, 10, 11, trunk] Segfault when error or warning should trigger with combination peeceseven at gmail dot com
                   ` (7 preceding siblings ...)
  2022-06-28 10:46 ` jakub at gcc dot gnu.org
@ 2023-07-07 10:41 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102987

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.5                        |11.5

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-07-07 10:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28 12:49 [Bug c++/102987] New: [9, 10, 11, trunk] Segfault when error or warning should trigger with combination peeceseven at gmail dot com
2021-10-28 12:50 ` [Bug c++/102987] [9,10,11,trunk] " peeceseven at gmail dot com
2021-10-28 12:52 ` peeceseven at gmail dot com
2021-10-29  6:38 ` [Bug c++/102987] [9/10/11/12 Regression] " rguenth at gcc dot gnu.org
2022-04-14 21:39 ` jason at gcc dot gnu.org
2022-04-15  1:00 ` cvs-commit at gcc dot gnu.org
2022-04-29 13:21 ` [Bug c++/102987] [9/10/11 " cvs-commit at gcc dot gnu.org
2022-05-27  9:46 ` [Bug c++/102987] [10/11 " rguenth at gcc dot gnu.org
2022-06-28 10:46 ` jakub at gcc dot gnu.org
2023-07-07 10:41 ` [Bug c++/102987] [11 " rguenth 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).