public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114632] New: ICE with explicit this in lambda
@ 2024-04-08  1:59 bruck.michael at gmail dot com
  2024-04-08  2:29 ` [Bug c++/114632] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: bruck.michael at gmail dot com @ 2024-04-08  1:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114632
           Summary: ICE with explicit this in lambda
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bruck.michael at gmail dot com
  Target Milestone: ---

struct S {};

auto lambda = [](this auto& self, const int x) {};

int main()
{
    void (*func)(S&, int) = lambda;
    return 0;
}

https://gcc.godbolt.org/z/3aW1be8PG

<source>: In substitution of 'template<class auto:1> constexpr<lambda(this
auto:1&, int)>::operator decltype (<lambda(this auto:1&,
int)>(static_cast<auto:1&>(self), static_cast<const int&&>(x))) (*)(auto:1&,
int)() const [with auto:1 = S]':
<source>:7:29:   required from here
    7 |     void (*func)(S&, int) = lambda;
      |                             ^~~~~~
<source>:3:15: internal compiler error: Segmentation fault
    3 | auto lambda = [](this auto& self, const int x) {};
      |               ^
0x26743fc internal_error(char const*, ...)
        ???:0
0xc9db80 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xc9d2c8 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xc9d032 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xc9d2c8 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xc85143 instantiate_template(tree_node*, tree_node*, int)
        ???:0
0xcb76d5 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
        ???:0
0xa8e3bf can_convert_arg_bad(tree_node*, tree_node*, tree_node*, int, int)
        ???:0
0xd38ca0 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0xb4618e cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
        ???:0
0xc5b3ea c_parse_file()
        ???:0
0xdaf8b9 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


clang compiles this snippet, which is probably incorrect.

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

* [Bug c++/114632] ICE with explicit this in lambda
  2024-04-08  1:59 [Bug c++/114632] New: ICE with explicit this in lambda bruck.michael at gmail dot com
@ 2024-04-08  2:29 ` pinskia at gcc dot gnu.org
  2024-04-15 21:20 ` waffl3x at protonmail dot com
  2024-04-15 22:16 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-08  2:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-04-08
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Keywords|                            |ice-on-valid-code

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

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

* [Bug c++/114632] ICE with explicit this in lambda
  2024-04-08  1:59 [Bug c++/114632] New: ICE with explicit this in lambda bruck.michael at gmail dot com
  2024-04-08  2:29 ` [Bug c++/114632] " pinskia at gcc dot gnu.org
@ 2024-04-15 21:20 ` waffl3x at protonmail dot com
  2024-04-15 22:16 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: waffl3x at protonmail dot com @ 2024-04-15 21:20 UTC (permalink / raw)
  To: gcc-bugs

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

waffl3x <waffl3x at protonmail dot com> changed:

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

--- Comment #2 from waffl3x <waffl3x at protonmail dot com> ---
I have a feeling Bug 112810 is related as providing a return type for
the lambda works around this bug.

struct S {};

auto lambda = [](this auto& self, const int x) -> void {};

int main()
{
    void (*func)(S&, int) = lambda;
    return 0;
}

https://gcc.godbolt.org/z/WE5qdvYcP

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

* [Bug c++/114632] ICE with explicit this in lambda
  2024-04-08  1:59 [Bug c++/114632] New: ICE with explicit this in lambda bruck.michael at gmail dot com
  2024-04-08  2:29 ` [Bug c++/114632] " pinskia at gcc dot gnu.org
  2024-04-15 21:20 ` waffl3x at protonmail dot com
@ 2024-04-15 22:16 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-15 22:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Looks like static op() lambdas are affected too:

struct S {};

auto lambda = [](auto, const int x) static /* -> void */ {};

int main()
{
    void (*func)(int, int) = lambda;
    return 0;
}

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

end of thread, other threads:[~2024-04-15 22:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-08  1:59 [Bug c++/114632] New: ICE with explicit this in lambda bruck.michael at gmail dot com
2024-04-08  2:29 ` [Bug c++/114632] " pinskia at gcc dot gnu.org
2024-04-15 21:20 ` waffl3x at protonmail dot com
2024-04-15 22:16 ` ppalka 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).