public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106052] New: ICE with -Wmismatched-tags with partially specialized friend struct of self type
@ 2022-06-22  4:03 beardsley.matt.j at gmail dot com
  2022-06-22  4:47 ` [Bug c++/106052] " beardsley.matt.j at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: beardsley.matt.j at gmail dot com @ 2022-06-22  4:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106052
           Summary: ICE with -Wmismatched-tags with partially specialized
                    friend struct of self type
           Product: gcc
           Version: 10.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: beardsley.matt.j at gmail dot com
  Target Milestone: ---

The following uses gcc built from a fresh repo that I just cloned earlier today
(default build settings)

tmp.cpp:
    template <typename T1, typename T2>
    struct S {
        template <typename, typename>
        struct S2;

        template <typename Type>
        struct S2<Type, bool> {};

        friend struct S2<S<T1, T2>, bool>;
    };


No ICE with warning off:
$ g++ -c tmp.cpp -o /dev/null -Wno-mismatched-tags
(no output)

ICE with warning on:
$ g++ -c tmp.cpp -o /dev/null -Wmismatched-tags
tmp.cpp: In substitution of ‘template<class Type> struct S<T1, T2>::S2<Type,
bool> [with Type = S<T1, T2>]’:
tmp.cpp:10:2:   required from here
tmp.cpp:10:2: internal compiler error: tree check: accessed elt 2 of ‘tree_vec’
with 1 elts in tsubst, at cp/pt.cc:15831
   10 | };
      |  ^
0x8ae378 tree_vec_elt_check_failed(int, int, char const*, int, char const*)
        ../.././gcc/tree.cc:9016
0x9d5d11 tree_vec_elt_check(tree_node*, int, char const*, int, char const*)
        ../.././gcc/tree.h:3737
0xb71967 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../.././gcc/cp/pt.cc:15831
0xb7ff0e tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ../.././gcc/cp/pt.cc:13580
0xb80132 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ../.././gcc/cp/pt.cc:13562
0xb6eca7 get_partial_spec_bindings
        ../.././gcc/cp/pt.cc:25457
0xb6f15b most_specialized_partial_spec(tree_node*, int)
        ../.././gcc/cp/pt.cc:25703
0xaf2970 specialization_of
        ../.././gcc/cp/parser.cc:33627
0xaf2970 class_decl_loc_t::diag_mismatched_tags(tree_node*)
        ../.././gcc/cp/parser.cc:33811
0xaf8db8 class_decl_loc_t::diag_mismatched_tags()
        ../.././gcc/cp/parser.cc:33935
0xb3c292 c_parse_file()
        ../.././gcc/cp/parser.cc:48376
0xc721d1 c_common_parse_file()
        ../.././gcc/c-family/c-opts.cc:1235
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

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

* [Bug c++/106052] ICE with -Wmismatched-tags with partially specialized friend struct of self type
  2022-06-22  4:03 [Bug c++/106052] New: ICE with -Wmismatched-tags with partially specialized friend struct of self type beardsley.matt.j at gmail dot com
@ 2022-06-22  4:47 ` beardsley.matt.j at gmail dot com
  2022-06-22 11:05 ` redi at gcc dot gnu.org
  2024-01-31 15:14 ` mpolacek at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: beardsley.matt.j at gmail dot com @ 2022-06-22  4:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Matt Beardsley <beardsley.matt.j at gmail dot com> ---
Just wanted to clarify that the prev. comment only reproduces with an asserted
build.

However, I first observed this in a 300,000+ LOC preprocessed file with a
release gcc build. But I could not stably minimize those reproduction steps
much further below that size.

But I found I could much more consistently hit an ICE using an asserted build
instead, which seems to add up given it looks like it's an out of range access
(which is what the assert is guarding)

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

* [Bug c++/106052] ICE with -Wmismatched-tags with partially specialized friend struct of self type
  2022-06-22  4:03 [Bug c++/106052] New: ICE with -Wmismatched-tags with partially specialized friend struct of self type beardsley.matt.j at gmail dot com
  2022-06-22  4:47 ` [Bug c++/106052] " beardsley.matt.j at gmail dot com
@ 2022-06-22 11:05 ` redi at gcc dot gnu.org
  2024-01-31 15:14 ` mpolacek at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2022-06-22 11:05 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
           Keywords|                            |ice-on-valid-code
             Status|UNCONFIRMED                 |NEW
                 CC|                            |msebor at gcc dot gnu.org
   Last reconfirmed|                            |2022-06-22

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The ICE is still present on trunk.

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

* [Bug c++/106052] ICE with -Wmismatched-tags with partially specialized friend struct of self type
  2022-06-22  4:03 [Bug c++/106052] New: ICE with -Wmismatched-tags with partially specialized friend struct of self type beardsley.matt.j at gmail dot com
  2022-06-22  4:47 ` [Bug c++/106052] " beardsley.matt.j at gmail dot com
  2022-06-22 11:05 ` redi at gcc dot gnu.org
@ 2024-01-31 15:14 ` mpolacek at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-31 15:14 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r10-7424-g04dd734b52de12:

commit 04dd734b52de121853e1ea6b3c197a598b294e23
Author: Martin Sebor <msebor@gmail.com>
Date:   Fri Mar 27 12:07:45 2020 -0400

    c++: avoid -Wredundant-tags on a first declaration in use [PR 93824]

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

end of thread, other threads:[~2024-01-31 15:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22  4:03 [Bug c++/106052] New: ICE with -Wmismatched-tags with partially specialized friend struct of self type beardsley.matt.j at gmail dot com
2022-06-22  4:47 ` [Bug c++/106052] " beardsley.matt.j at gmail dot com
2022-06-22 11:05 ` redi at gcc dot gnu.org
2024-01-31 15:14 ` 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).