public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105667] New: Internal compiler segmentation fault
@ 2022-05-19 23:22 akira65535 at protonmail dot com
  2022-05-19 23:34 ` [Bug c++/105667] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: akira65535 at protonmail dot com @ 2022-05-19 23:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105667
           Summary: Internal compiler segmentation fault
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: akira65535 at protonmail dot com
  Target Milestone: ---

Created attachment 53003
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53003&action=edit
Simple cpp file which causes the bug

~ $ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/12.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-12.1.0/work/gcc-12.1.0/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/12.1.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/12.1.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/12.1.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/12.1.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/include/g++-v12
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/12.1.0/python
--enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt
--disable-werror --with-system-zlib --enable-nls --without-included-gettext
--disable-libunwind-exceptions --enable-checking=release
--with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 12.1.0 p5'
--disable-esp --enable-libstdcxx-time --disable-libstdcxx-pch --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point
--enable-targets=all --enable-libgomp --disable-libssp --disable-libada
--disable-cet --disable-systemtap --disable-valgrind-annotations
--disable-vtable-verify --disable-libvtv --without-zstd --enable-lto
--without-isl --enable-default-pie --enable-default-ssp
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.1.0 (Gentoo 12.1.0 p5)


 ~ $ g++ -std=c++20 test.cpp
test.cpp: In instantiation of ‘Example<int, int>::crash()::<lambda()> [with
long unsigned int i = 0]’:
test.cpp:17:10:   required from ‘static void Example<Ts>::crash() [with Ts =
{int, int}]’
test.cpp:22:29:   required from here
test.cpp:8:37: internal compiler error: Segmentation fault
    8 |     using Types = typename lambda_t<[] <typename T> () {}>::type;
      |                                     ^~~~~~~~~~~~~~~~~~~~~
0x1b4314e internal_error(char const*, ...)
        ???:0
0x7fbb64 template_parms_to_args(tree_node*)
        ???:0
0x82916e tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x80bd96 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ???:0
0x82093f tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x814165 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x82093f tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x813bbc tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x81335d tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x81add9 instantiate_decl(tree_node*, bool, bool)
        ???:0
0x72e94f mark_used(tree_node*, int)
        ???:0
0x6b4f8a build_op_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
        ???:0
0x840d98 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0x80a61e tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ???:0
0x81add9 instantiate_decl(tree_node*, bool, bool)
        ???:0
0x82fb1b instantiate_pending_templates(int)
        ???:0
0x730608 c_parse_final_cleanups()
        ???:0

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

* [Bug c++/105667] Internal compiler segmentation fault
  2022-05-19 23:22 [Bug c++/105667] New: Internal compiler segmentation fault akira65535 at protonmail dot com
@ 2022-05-19 23:34 ` pinskia at gcc dot gnu.org
  2022-05-19 23:47 ` [Bug c++/105667] [C++20] lambas in template argument sometimes causes an ICE (seg fault) pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-19 23:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase without the need for tuple includes:
template<auto f>
struct h {typedef int type;};

template<int I, class... Types>
struct t{};

template<typename Ts>
struct Example {
    using Types = typename h<[] <typename T> () {}>::type;

    static void crash() {
        auto f = [&] <int i=0> () {
            using type = t<0, Types>();
        };

        f();
    }
};

int main() {
    Example<int>::crash();
    return 0;
}

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

* [Bug c++/105667] [C++20] lambas in template argument sometimes causes an ICE (seg fault)
  2022-05-19 23:22 [Bug c++/105667] New: Internal compiler segmentation fault akira65535 at protonmail dot com
  2022-05-19 23:34 ` [Bug c++/105667] " pinskia at gcc dot gnu.org
@ 2022-05-19 23:47 ` pinskia at gcc dot gnu.org
  2022-05-19 23:48 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-19 23:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[C++20] templated lambas in |[C++20] lambas in template
                   |template argument sometimes |argument sometimes causes
                   |causes an ICE (seg fault)   |an ICE (seg fault)

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. something slightly shorter, changing the class template to a
function template and changing some other things slightly too.
problem is related to lamba as a template argument.

template<auto f>
struct h {typedef int type;};

template<class Types>
struct t{};

template<typename Ts>
void crash() {
    using Types = typename h<[]() {}>::type;
    auto f = [&] <int i> () {
        using type = t<Types>;
    };
    f.template operator()<1>();
}

int main() {
    crash<int>();
    return 0;
}

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

* [Bug c++/105667] [C++20] lambas in template argument sometimes causes an ICE (seg fault)
  2022-05-19 23:22 [Bug c++/105667] New: Internal compiler segmentation fault akira65535 at protonmail dot com
  2022-05-19 23:34 ` [Bug c++/105667] " pinskia at gcc dot gnu.org
  2022-05-19 23:47 ` [Bug c++/105667] [C++20] lambas in template argument sometimes causes an ICE (seg fault) pinskia at gcc dot gnu.org
@ 2022-05-19 23:48 ` pinskia at gcc dot gnu.org
  2022-05-19 23:51 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-19 23:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
here is one which removes the inner lamba to just a templated function inside a
template struct:

template<auto f>
struct h {typedef int type;};

template<class Types>
struct t{};

template<typename Ts>
struct crash {
    using Types = typename h<[]() {}>::type;
    template<int tt>
    static void f()
    {
        using type = t<Types>;
    };
};

int main() {
    crash<int>{}.f<1>();
    return 0;
}

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

* [Bug c++/105667] [C++20] lambas in template argument sometimes causes an ICE (seg fault)
  2022-05-19 23:22 [Bug c++/105667] New: Internal compiler segmentation fault akira65535 at protonmail dot com
                   ` (2 preceding siblings ...)
  2022-05-19 23:48 ` pinskia at gcc dot gnu.org
@ 2022-05-19 23:51 ` pinskia at gcc dot gnu.org
  2022-05-20  7:50 ` marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-19 23:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-05-19
     Ever confirmed|0                           |1

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

Another slightly more reduced testcase:
template<auto f>
struct h {typedef int type;};

template<class Types>
struct t{};

template<int Ts>
struct crash {
    using Types = typename h<[]() {}>::type;
    template<int tt>
    static void f()
    {
        t<Types> b;
    };
};

int main() {
    crash<0>::f<1>();
    return 0;
}

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

* [Bug c++/105667] [C++20] lambas in template argument sometimes causes an ICE (seg fault)
  2022-05-19 23:22 [Bug c++/105667] New: Internal compiler segmentation fault akira65535 at protonmail dot com
                   ` (3 preceding siblings ...)
  2022-05-19 23:51 ` pinskia at gcc dot gnu.org
@ 2022-05-20  7:50 ` marxin at gcc dot gnu.org
  2022-09-04 17:40 ` pobrn at protonmail dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-05-20  7:50 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
Likely started with r9-4045-g0c1e0d63fe0ceabb, it was rejected before the
revision.

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

* [Bug c++/105667] [C++20] lambas in template argument sometimes causes an ICE (seg fault)
  2022-05-19 23:22 [Bug c++/105667] New: Internal compiler segmentation fault akira65535 at protonmail dot com
                   ` (4 preceding siblings ...)
  2022-05-20  7:50 ` marxin at gcc dot gnu.org
@ 2022-09-04 17:40 ` pobrn at protonmail dot com
  2023-05-08 21:27 ` eric.niebler at gmail dot com
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pobrn at protonmail dot com @ 2022-09-04 17:40 UTC (permalink / raw)
  To: gcc-bugs

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

Barnabás Pőcze <pobrn at protonmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pobrn at protonmail dot com

--- Comment #6 from Barnabás Pőcze <pobrn at protonmail dot com> ---
Another snippet that I believe triggers the same issue:

template<typename>
struct get { };

template<int>
struct thing {
    using T = decltype([](auto) { });

    static constexpr auto value = [](auto) {
        return get<T>();
    }(0);
};

thing<0> X;

---

In this case template_parms_to_args() is called with a nullptr.

template_parms_to_args (parms=0x0) at /usr/src/debug/gcc/gcc/cp/pt.cc:4912

tsubst_template_decl (t=0x7ffff7177280, args=<optimized out>, complain=3,
lambda_fntype=0x7ffff717b738) at /usr/src/debug/gcc/gcc/cp/pt.cc:14543

tsubst_lambda_expr (t=<optimized out>, args=0x7ffff7171d80, complain=3,
in_decl=0x7ffff7173800) at /usr/src/debug/gcc/gcc/cp/pt.cc:19855

tsubst_copy_and_build (t=<optimized out>, args=0x7ffff7171d80,
complain=<optimized out>, in_decl=0x7ffff7177000, function_p=<optimized out>,
integral_constant_expression_p=false) at /usr/src/debug/gcc/gcc/cp/pt.cc:21446

tsubst (t=0x7ffff71760a8, args=0x7ffff7171d80, complain=3,
in_decl=0x7ffff7177000) at /usr/src/debug/gcc/gcc/cp/pt.cc:16400

tsubst_template_args (t=0x7ffff7171a20, args=args@entry=0x7ffff7171d80,
complain=complain@entry=3, in_decl=in_decl@entry=0x7ffff7177000) at
/usr/src/debug/gcc/gcc/cp/pt.cc:13580

[...]

---

GCC 12.2.0, but GCC trunk on Compiler Explorer also exhibits the same issue (as
do GCC 11.1, 11.2, 11.3, 12.1, and 12.2)

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

* [Bug c++/105667] [C++20] lambas in template argument sometimes causes an ICE (seg fault)
  2022-05-19 23:22 [Bug c++/105667] New: Internal compiler segmentation fault akira65535 at protonmail dot com
                   ` (5 preceding siblings ...)
  2022-09-04 17:40 ` pobrn at protonmail dot com
@ 2023-05-08 21:27 ` eric.niebler at gmail dot com
  2023-06-30 19:56 ` blubban at gmail dot com
  2024-04-13 20:24 ` [Bug c++/105667] [C++20] lambdas in template argument sometimes cause " pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: eric.niebler at gmail dot com @ 2023-05-08 21:27 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Niebler <eric.niebler at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eric.niebler at gmail dot com

--- Comment #7 from Eric Niebler <eric.niebler at gmail dot com> ---
Another, even shorter repro:

template <auto A = []<class B>(B){}>
struct C {
  using D = void;
};

template <class...>
using E = C<>::D;

using F = E<>;

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

* [Bug c++/105667] [C++20] lambas in template argument sometimes causes an ICE (seg fault)
  2022-05-19 23:22 [Bug c++/105667] New: Internal compiler segmentation fault akira65535 at protonmail dot com
                   ` (6 preceding siblings ...)
  2023-05-08 21:27 ` eric.niebler at gmail dot com
@ 2023-06-30 19:56 ` blubban at gmail dot com
  2024-04-13 20:24 ` [Bug c++/105667] [C++20] lambdas in template argument sometimes cause " pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: blubban at gmail dot com @ 2023-06-30 19:56 UTC (permalink / raw)
  To: gcc-bugs

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

Alfred Agrell <blubban at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |blubban at gmail dot com

--- Comment #8 from Alfred Agrell <blubban at gmail dot com> ---
I ran into something similar. My reduced testcase is


struct class1
{
        virtual void a_function() = 0;
};

template<auto my_lambda = []<typename T>() {}>
class class2 {};

template<typename Touter>
struct class3 : public class1 {
        void a_function()
        {
                class2<> x;
        }
};

struct class4 : public class3<class4> {
        class4() {}
};


https://godbolt.org/z/GKo5oWe8j

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

* [Bug c++/105667] [C++20] lambdas in template argument sometimes cause an ICE (seg fault)
  2022-05-19 23:22 [Bug c++/105667] New: Internal compiler segmentation fault akira65535 at protonmail dot com
                   ` (7 preceding siblings ...)
  2023-06-30 19:56 ` blubban at gmail dot com
@ 2024-04-13 20:24 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-13 20:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2022-05-19 00:00:00         |2024-4-13

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Eric Niebler from comment #7)
> Another, even shorter repro:

This one is fixed for GCC 14 with the recent lambda template patches.

(In reply to Alfred Agrell from comment #8)
> I ran into something similar. My reduced testcase is

Likewise.

But the others still ICEs today on the trunk.

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

end of thread, other threads:[~2024-04-13 20:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 23:22 [Bug c++/105667] New: Internal compiler segmentation fault akira65535 at protonmail dot com
2022-05-19 23:34 ` [Bug c++/105667] " pinskia at gcc dot gnu.org
2022-05-19 23:47 ` [Bug c++/105667] [C++20] lambas in template argument sometimes causes an ICE (seg fault) pinskia at gcc dot gnu.org
2022-05-19 23:48 ` pinskia at gcc dot gnu.org
2022-05-19 23:51 ` pinskia at gcc dot gnu.org
2022-05-20  7:50 ` marxin at gcc dot gnu.org
2022-09-04 17:40 ` pobrn at protonmail dot com
2023-05-08 21:27 ` eric.niebler at gmail dot com
2023-06-30 19:56 ` blubban at gmail dot com
2024-04-13 20:24 ` [Bug c++/105667] [C++20] lambdas in template argument sometimes cause " pinskia 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).