[Bug c++/115053] New: gcc crashed without back trace

2024-05-12 Thread rungecc at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115053

Bug ID: 115053
   Summary: gcc crashed without back trace
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rungecc at gmail dot com
  Target Milestone: ---

Minimal example(https://godbolt.org/z/qPKaYdj4o):

```c++
template < typename... Ts >
struct list {};

template < typename... Ts >
constexpr
bool ice = []( list x = {}) { 
return true;
}();

constexpr auto r = ice;
```

GCC just crashes, without any useful diagnostics or internal reports, possibly
runs into an infinite loop when it performs mangling (the crash of clang is
this type).

[Bug c++/112273] New: gcc crashs when checking satisfaction a constraint of lambda function

2023-10-29 Thread rungecc at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112273

Bug ID: 112273
   Summary: gcc crashs when checking satisfaction a constraint of
lambda function
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rungecc at gmail dot com
  Target Milestone: ---

Created attachment 56468
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56468&action=edit
ICE output

```c++
template  struct Tp {};

template  struct make_delayed {
  static constexpr inline bool value = true;
};

template 
concept K = make_delayed::value;

[[maybe_unused]] constexpr auto ice(auto... arg) {
  using Tp_t = Tp;
  return []()
requires K
  { return 1; };
};

int main() {
  constexpr auto l = ice(1, 2);
  static_assert(l() == 1);
  return 0;
}
```

See also [online compiler](https://godbolt.org/z/r8K4bK199).

Gcc (checked version 14.0, 13.2, 12.3) with flag `-std=c++2b` crashed on the
above code snippets.

Output, see the attachment.

**NOTE**:

Seems we need 1) a dependent constraint attached to some function and 2) such
constraint refers to a type contains a (dependent) pack expansion in it's
definition to trigger this ICE.

[Bug c++/115053] gcc crashed without back trace

2024-06-14 Thread rungecc at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115053

--- Comment #2 from Chromo Runge  ---
Created attachment 58434
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58434&action=edit
local crash

[Bug c++/115053] gcc crashed without back trace

2024-06-14 Thread rungecc at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115053

--- Comment #3 from Chromo Runge  ---
(In reply to Marek Polacek from comment #1)
> Can't reproduce:
> 
> $ time ./cc1plus -quiet 115053.C -std=c++20
> 
> real  0m0.016s
> user  0m0.010s
> sys   0m0.006s
> 
> same with gcc 14 and 13.

It seems that this happens with flag `-g`, see attachment, reproduced in my
local gcc.

[Bug c++/115773] New: gcc crashed with a init-capture which introduces a pack inside another lambda

2024-07-03 Thread rungecc at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115773

Bug ID: 115773
   Summary: gcc crashed with a init-capture which introduces a
pack inside another lambda
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rungecc at gmail dot com
  Target Milestone: ---

```c++
// g++ -std=c++26 main.cpp
constexpr auto gcc_ice(auto&& func) noexcept {
return [](Ts&&...) noexcept { return ((void)[... args1=Ts{}]
{}, false); };
}

int main() { (void)(gcc_ice(1)()); }

```


See online compiler: https://godbolt.org/z/q9hac3nhY

Stacktrace:

```
: In instantiation of 'constexpr auto gcc_ice(auto:1&&) [with auto:1 =
int]':
:5:28:   required from here
5 | int main() { (void)(gcc_ice(1)()); }
  | ~~~^~~
:2:76: internal compiler error: Segmentation fault
2 | return [](Ts&&...) noexcept { return ((void)[...
args1=Ts{}] {}, false); };
  |
   ^
0x26de735 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, int, char const*, __va_list_tag (*) [1],
diagnostic_t)
???:0
0x26ec2e2 internal_error(char const*, ...)
???:0
0xcb7369 tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*)
???:0
0xcc4757 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0xcb7fbb tsubst_tree_list(tree_node*, tree_node*, int, tree_node*)
???:0
0xcc50cd tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0xca7b03 instantiate_decl(tree_node*, bool, bool)
???:0
0xb65035 maybe_instantiate_decl(tree_node*)
???:0
0xb66c86 mark_used(tree_node*, int)
???:0
0xa94d3e build_new_function_call(tree_node*, vec**, int)
???:0
0xcede1e finish_call_expr(tree_node*, vec**, bool,
bool, int)
???:0
0xc702da c_parse_file()
???:0
0xdc6e39 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  for instructions.
Compiler returned: 1
```

[Bug c++/115852] New: gcc crashed in diagnostic_context::diagnostic_impl when using a explicit object lambda inside requires clause

2024-07-09 Thread rungecc at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115852

Bug ID: 115852
   Summary: gcc crashed in diagnostic_context::diagnostic_impl
when using a explicit object lambda inside requires
clause
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rungecc at gmail dot com
  Target Milestone: ---

Reproducer (see online compiler https://godbolt.org/z/Wafce5v1Y):

```
// g++ -std=c++26 main.cpp
template
auto x(Ts0&&...  ) requires requires {
[](this Self&&) {

};
} {
return 0;
}

int main() {
return x(1);
}

```

Stacktrace:

```
: In substitution of 'template auto x(Ts0&& ...)
requires requires{;} [with Ts0 = {int}]':
:11:13:   required from here
   11 | return x(1);
  |~^~~
:3:5: internal compiler error: in satisfy_declaration_constraints, at
cp/constraint.cc:3290
3 | [](this Self&&) {
  | ^
4 | 
  |  
5 | };
  | ~
0x26e53e5 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, int, char const*, __va_list_tag (*) [1],
diagnostic_t)
???:0
0x26f2f92 internal_error(char const*, ...)
???:0
0xa671ce fancy_abort(char const*, int, char const*)
???:0
0xaeca58 constraints_satisfied_p(tree_node*, tree_node*)
???:0
0xb68589 mark_used(tree_node*, int)
???:0
0xb691b0 mark_single_function(tree_node*, int)
???:0
0xb97f27 maybe_add_lambda_conv_op(tree_node*)
???:0
0xcc69ec tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0xaeb076 tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0xaeca58 constraints_satisfied_p(tree_node*, tree_node*)
???:0
0xcce6e3 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
???:0
0xa96599 build_new_function_call(tree_node*, vec**, int)
???:0
0xcef6ce finish_call_expr(tree_node*, vec**, bool,
bool, int)
???:0
0xc71afa c_parse_file()
???:0
0xdc86d9 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  for instructions.
Compiler returned: 1
```

[Bug c++/119233] New: inside a template function the tracking of whether a member function pointer of a class template escapes is wrong

2025-03-11 Thread rungecc at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119233

Bug ID: 119233
   Summary: inside a template function the tracking of whether a
member function pointer of a class template escapes is
wrong
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: rungecc at gmail dot com
  Target Milestone: ---

Reproducer (see online compiler: https://godbolt.org/z/bKh6vPjMv and
https://godbolt.org/z/rMs4dxje9)
```
// g++ -g -std=c++20 -O2
template 
struct foo {
int get() { return 0; }
};

void register_f(void* data) {
foo<0> f;
auto mp = *static_cast::get)*>(data);
auto res = (f.*mp)();
}

template 
void set() {
auto&& f = Func;
register_f(&f);
}

// whether helper is a generic function or a generic lambda does not matter.
// template 
// void helper() {
// set<&foo<0>::get>();
// };


int main() {
auto helper = [&]() { set<&foo<0>::get>(); };
helper();
return 0;
}
```

Expected behavior: successfully complied and linked, just like `clang++` and
`msvc` do.

Actual behavior: ams gen succeeds, but `ld` complains:
```
in function `register_f(void*)':
:11:(.text.startup+0xa): undefined reference to `foo<0>::get()'
collect2: error: ld returned 1 exit status
```

Workaround: if explicitly instantiate `class foo<0>`, the issue is gone, see
online compiler (https://godbolt.org/z/o3fKrrGr1).

Version:

g++
(Compiler-Explorer-Build-gcc-c6b277f1dc6d11ad6d398967b8d645e7c3c6ad71-binutils-2.42)
15.0.1 20250311 (experimental)