public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101430] New: Passing a lambda as a template argument causes internal compiler error
@ 2021-07-13  1:17 jorg.brown at gmail dot com
  2021-07-13 11:06 ` [Bug c++/101430] " redi at gcc dot gnu.org
  2022-11-02  0:29 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: jorg.brown at gmail dot com @ 2021-07-13  1:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101430
           Summary: Passing a lambda as a template argument causes
                    internal compiler error
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jorg.brown at gmail dot com
  Target Milestone: ---

This code causes gcc 11.1.0 to ICE:
////////////////////
extern "C" {
  int printf(const char *, ...);
}

void g(int n) { printf("%d\n", n); }

template<auto Lambda = []{ g(1);} > void f(decltype(Lambda) x = {}) {
    x();
}

int main() {
    constexpr auto a = []{ g(3); };
//    f<a>();

    f<[]{g(2);}>();

    f();
}
////////////////////
Output when compiled:


x86-64 gcc 11.1 (Editor #1, Compiler #1) C++
x86-64 gcc 11.1
-std=c++20 
123
<Compilation failed>

# For more information see the output window
x86-64 gcc 11.1 - cached
Output of x86-64 gcc 11.1 (Compiler #1)
<source>: In substitution of 'template<auto Lambda> void f(decltype (Lambda))
[with auto Lambda = <missing>]':
<source>:17:6:   required from here
<source>:7:33: internal compiler error: in convert_nontype_argument, at
cp/pt.c:7652
    7 | template<auto Lambda = []{ g(1);} > void f(decltype(Lambda) x = {}) {
      |                                 ^
0x1780bf9 internal_error(char const*, ...)
        ???:0
0x677e40 fancy_abort(char const*, int, char const*)
        ???:0
0x7f3b4b fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
        ???:0
0x68eda2 build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0x8070f0 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0x7c0cab c_parse_file()
        ???:0
0x892aa2 c_common_parse_file()
        ???:0
////////////////////
Compiler Explorer link: https://godbolt.org/z/Evcd7oaz5
////////////////////

Interestingly, if I comment out the definition of `a`, it compiles and runs
properly.

And if I comment out either of the last two calls to f(), it compiles and runs
properly.  Whether or not f<a>(); is commented out.

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

* [Bug c++/101430] Passing a lambda as a template argument causes internal compiler error
  2021-07-13  1:17 [Bug c++/101430] New: Passing a lambda as a template argument causes internal compiler error jorg.brown at gmail dot com
@ 2021-07-13 11:06 ` redi at gcc dot gnu.org
  2022-11-02  0:29 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2021-07-13 11:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |ice-on-valid-code
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-07-13

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Confirmed. Not a regression.

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

* [Bug c++/101430] Passing a lambda as a template argument causes internal compiler error
  2021-07-13  1:17 [Bug c++/101430] New: Passing a lambda as a template argument causes internal compiler error jorg.brown at gmail dot com
  2021-07-13 11:06 ` [Bug c++/101430] " redi at gcc dot gnu.org
@ 2022-11-02  0:29 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-02  0:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |needs-bisection
      Known to work|                            |12.2.0, 13.0
      Known to fail|                            |12.1.0

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looks to be fixed in GCC 12.2.0 and the trunk.

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

end of thread, other threads:[~2022-11-02  0:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13  1:17 [Bug c++/101430] New: Passing a lambda as a template argument causes internal compiler error jorg.brown at gmail dot com
2021-07-13 11:06 ` [Bug c++/101430] " redi at gcc dot gnu.org
2022-11-02  0:29 ` 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).