public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113349] New: internal compiler error: in tsubst
@ 2024-01-12  9:16 federico at kircheis dot it
  2024-01-12  9:28 ` [Bug c++/113349] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: federico at kircheis dot it @ 2024-01-12  9:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113349
           Summary: internal compiler error: in tsubst
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: federico at kircheis dot it
  Target Milestone: ---

While trying to destructure a tuple, I got this internal compiler error

----
<source>: In substitution of 'template<class T> template<long unsigned int N>
using types<T, decltype ((<lambda>(), void()))>::el = std::tuple_element_t<N,
decltype (<lambda>())> [with long unsigned int N = 1; T = s]':
<source>:36:50:   required from here
   36 | static_assert(std::is_same_v<char*, types<s>::el<1>>);
      |                                                  ^
<source>:7:28: internal compiler error: in tsubst, at cp/pt.cc:16312
    7 | #define MAKE_TUPLE(V, ...) []{\
      |                            ^~~~
    8 |     auto [ __VA_ARGS__ ] = makeV<V>(); \
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    9 |     return std::make_tuple( __VA_ARGS__);\
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   10 | }()
      | ~                           
<source>:19:26: note: in expansion of macro 'MAKE_TUPLE'
   19 | struct types<T, decltype(MAKE_TUPLE(T, e0, e1, e2), void())> {
      |                          ^~~~~~~~~~
0x2640f8c internal_error(char const*, ...)
        ???:0
0xa502dd fancy_abort(char const*, int, char const*)
        ???:0
0xc92c62 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xca446c tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xc93417 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xc99729 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xc7c365 instantiate_template(tree_node*, tree_node*, int)
        ???:0
0xc9420c tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xc914dc lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
        ???:0
0xccd98f finish_template_type(tree_node*, tree_node*, int)
        ???:0
0xc51fda c_parse_file()
        ???:0
0xda59d9 c_common_parse_file()
        ???:0
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.
Compiler returned: 1
----

The code looks like

----
#include <tuple>
#include <utility>

template <class V>
V makeV();

#define MAKE_TUPLE(V, ...) []{\
    auto [ __VA_ARGS__ ] = makeV<V>(); \
    return std::make_tuple( __VA_ARGS__);\
}()


template <typename T, typename = void>
struct types{
    using type = void;
};

template <typename T>
struct types<T, decltype(MAKE_TUPLE(T, e0, e1, e2), void())> {
    template<std::size_t N>
    using el = std::tuple_element_t<N, decltype(MAKE_TUPLE(T, e0, e1, e2))>;
};
/*
template <typename T>
struct types<T, decltype(MAKE_TUPLE(T, e1), void())> {
    template<std::size_t N>
    using el = std::tuple_element_t<N, decltype(MAKE_TUPLE(T, e1))>;
};
*/
struct s{
    int& i;
    char* b;
    float f;
};
//static_assert(std::is_same_v<int&, types<s>::el<0>>); // fails
static_assert(std::is_same_v<char*, types<s>::el<1>>);
static_assert(std::is_same_v<float, types<s>::el<2>>);
----

This code compiles fine with clang and MSVC, and is, to the best of my
knowledge, valid C++

Online example with latest gcc (and clang msvc too)

https://godbolt.org/z/sPxK5avEW

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

* [Bug c++/113349] internal compiler error: in tsubst
  2024-01-12  9:16 [Bug c++/113349] New: internal compiler error: in tsubst federico at kircheis dot it
@ 2024-01-12  9:28 ` pinskia at gcc dot gnu.org
  2024-01-18 17:51 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-12  9:28 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |c++-lambda,
                   |                            |ice-on-valid-code
             Blocks|                            |107430

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
lambdas in decltypes are definitely one area where GCC has known issues.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107430
[Bug 107430] [meta-bug] lambda in decltype

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

* [Bug c++/113349] internal compiler error: in tsubst
  2024-01-12  9:16 [Bug c++/113349] New: internal compiler error: in tsubst federico at kircheis dot it
  2024-01-12  9:28 ` [Bug c++/113349] " pinskia at gcc dot gnu.org
@ 2024-01-18 17:51 ` mpolacek at gcc dot gnu.org
  2024-01-18 18:48 ` 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-18 17:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-01-18
     Ever confirmed|0                           |1
                 CC|                            |mpolacek at gcc dot gnu.org
           Keywords|                            |needs-reduction
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed; I'll try to reduce it.

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

* [Bug c++/113349] internal compiler error: in tsubst
  2024-01-12  9:16 [Bug c++/113349] New: internal compiler error: in tsubst federico at kircheis dot it
  2024-01-12  9:28 ` [Bug c++/113349] " pinskia at gcc dot gnu.org
  2024-01-18 17:51 ` mpolacek at gcc dot gnu.org
@ 2024-01-18 18:48 ` mpolacek at gcc dot gnu.org
  2024-01-18 19:01 ` mpolacek at gcc dot gnu.org
  2024-01-18 19:03 ` [Bug c++/113349] [11/12/13/14 Regression] " mpolacek at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-18 18:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-reduction             |

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
// PR c++/113349

template <typename> void is_same_v();
template <long, typename _Tp> using tuple_element_t = _Tp;
template <typename, typename = void> struct types;
template <typename T> struct types<T, decltype([] {}())> {
  template <long N> using el = tuple_element_t<N, decltype([] {})>;
};
static_assert(is_same_v<types<int>::el<1>>);

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

* [Bug c++/113349] internal compiler error: in tsubst
  2024-01-12  9:16 [Bug c++/113349] New: internal compiler error: in tsubst federico at kircheis dot it
                   ` (2 preceding siblings ...)
  2024-01-18 18:48 ` mpolacek at gcc dot gnu.org
@ 2024-01-18 19:01 ` mpolacek at gcc dot gnu.org
  2024-01-18 19:03 ` [Bug c++/113349] [11/12/13/14 Regression] " mpolacek at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-18 19:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Looks like the ICE started with r11-7095:

commit 7b258ac7afaaf7d8157df10ea35c6002d935d7d0
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Feb 1 17:24:05 2021 -0500

    c++: subst failure in attribute argument [PR95192]

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

* [Bug c++/113349] [11/12/13/14 Regression] internal compiler error: in tsubst
  2024-01-12  9:16 [Bug c++/113349] New: internal compiler error: in tsubst federico at kircheis dot it
                   ` (3 preceding siblings ...)
  2024-01-18 19:01 ` mpolacek at gcc dot gnu.org
@ 2024-01-18 19:03 ` mpolacek at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-18 19:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
            Summary|internal compiler error: in |[11/12/13/14 Regression]
                   |tsubst                      |internal compiler error: in
                   |                            |tsubst
   Target Milestone|---                         |11.5

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Before:

error: cannot resolve overloaded function ‘is_same_v’ based on conversion to
type ‘bool’
    9 | static_assert(is_same_v<types<int>::el<1>>);
      |                                            ^

still, a regression.  clang++ accepts the reduced code.

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

end of thread, other threads:[~2024-01-18 19:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-12  9:16 [Bug c++/113349] New: internal compiler error: in tsubst federico at kircheis dot it
2024-01-12  9:28 ` [Bug c++/113349] " pinskia at gcc dot gnu.org
2024-01-18 17:51 ` mpolacek at gcc dot gnu.org
2024-01-18 18:48 ` mpolacek at gcc dot gnu.org
2024-01-18 19:01 ` mpolacek at gcc dot gnu.org
2024-01-18 19:03 ` [Bug c++/113349] [11/12/13/14 Regression] " 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).