[Bug c++/78216] Segfault when dealing with a parameter pack of member functions pointers

2024-11-19 Thread gcc.gnu.org at ajryansolutions dot co.uk via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78216

Adam Ryan  changed:

   What|Removed |Added

 CC||gcc.gnu.org@ajryansolutions
   ||.co.uk

--- Comment #3 from Adam Ryan  ---
I think I am encountering the same issue. Here is a minimised example from the
code I was working on:


template using MemberFunction = void (T::*)(P);

template class MemberFunctions;
// template F> class
MemberFunctions
template...F> class
MemberFunctions
{
public: void apply( E e, bool value ){ e.write(value); }
};

class Writer{ public: void write( bool ){} };

int main()
{
MemberFunctions().apply( Writer(), true );
}


If the commented out line is put in place of the line below it then it compiles
fine so it is specifically the addition of the parameter packs that cause the
issue.
You can test this in godbolt (https://godbolt.org/) using the x86-64 gcc 14.2
compiler and also that when the compiler is set to x86-64 clang 19.1.0 it
compiles without issue.
If set to the trunk version of gcc it gives a stack trace to where it fails:


:15:1: internal compiler error: Segmentation fault
   15 | }
  | ^
0x28b0815 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x28c7515 internal_error(char const*, ...)
???:0
0xeb2898 symbol_table::decl_assembler_name_hash(tree_node const*)
???:0
0xeb6b14 symtab_node::get_for_asmname(tree_node const*)
???:0
0xeb6c31 symtab_node::verify_base()
???:0
0xec7e2d cgraph_node::verify_node()
???:0
0xeb77c4 symtab_node::verify()
???:0
0xeb89a7 symtab_node::verify_symtab_nodes()
???:0
0xed172b symbol_table::finalize_compilation_unit()
???: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


I tried debugging it and when reaching here
https://gcc.gnu.org/git?p=gcc.git;a=blob;f=gcc/symtab.cc;h=762a6236ca1e199ab0b5aa78ba51624d72900ecd;hb=refs/heads/master#l1159
 
the MACRO DECL_ASSEMBLER_NAME is returning a null pointer for the assembler
name i.e (NODE)->decl_with_vis.assembler_name is not populated and null. Seems
to be related to set_decl_assembler_name in langhooks which I haven't gone into
so far.

I'd be interested to know if this is a bug or if it's a missing feature as if
it's not too big I'd have a go.

[Bug c++/118265] New: Failure in resolving non-type template parameters with nested parameter pack of form ...B>

2025-01-01 Thread gcc.gnu.org at ajryansolutions dot co.uk via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118265

Bug ID: 118265
   Summary: Failure in resolving non-type template parameters with
nested parameter pack of form
...B>
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc.gnu.org at ajryansolutions dot co.uk
  Target Milestone: ---

I originally reported the problem in Bug 78216
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78216) and having investigated it
further found it is a separate problem that the following example better
demonstrates.


template struct Class1{};

template class Class2;
template...Un> class Class2
{
public: void apply(){}
};

Class1 class1_bool;
Class1 class1_char;

int main()
{
Class2 class2;
class2.apply();
}


When the compiler is resolving Un it fails to explore V for the associated
parameter pack V and leads to an unknown placeholder in the the template when
creating the instance class2, this then leads to it's first and fatal failure
when it tries to get the assembly name for it:

:15:1: internal compiler error: Segmentation fault
   15 | }
  | ^
0x28b0815 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x28c7515 internal_error(char const*, ...)
???:0
0xeb2898 symbol_table::decl_assembler_name_hash(tree_node const*)
???:0
0xeb6b14 symtab_node::get_for_asmname(tree_node const*)
???:0
0xeb6c31 symtab_node::verify_base()
???:0
0xec7e2d cgraph_node::verify_node()
???:0
0xeb77c4 symtab_node::verify()
???:0
0xeb89a7 symtab_node::verify_symtab_nodes()
???:0
0xed172b symbol_table::finalize_compilation_unit()
???: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++/118265] Failure in resolving non-type template parameters with nested parameter pack of form ...B>

2025-01-01 Thread gcc.gnu.org at ajryansolutions dot co.uk via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118265

--- Comment #1 from Adam Ryan  ---
Created attachment 60026
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60026&action=edit
Patch that has been submitted for review.

I've submitted a patch for review.

[Bug c++/78216] Segfault when dealing with a parameter pack of member functions pointers

2025-01-01 Thread gcc.gnu.org at ajryansolutions dot co.uk via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78216

--- Comment #6 from Adam Ryan  ---
After investigating this further I have found that the issue I encountered had
a different root cause and I've created a new PR for it here
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118265.

[Bug c++/78216] Segfault when dealing with a parameter pack of member functions pointers

2024-12-26 Thread gcc.gnu.org at ajryansolutions dot co.uk via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78216

--- Comment #4 from Adam Ryan  ---
Created attachment 59981
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59981&action=edit
An example code change that will allow the code to compile.

[Bug c++/78216] Segfault when dealing with a parameter pack of member functions pointers

2024-12-26 Thread gcc.gnu.org at ajryansolutions dot co.uk via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78216

--- Comment #5 from Adam Ryan  ---
I should the patch only allows the code snippet I posted to compile, the code
from the original poster has a different exception however I think the eventual
solution may be common to both.

[Bug c++/118265] Failure in resolving non-type template parameters with nested parameter pack of form ...B>

2025-01-05 Thread gcc.gnu.org at ajryansolutions dot co.uk via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118265

--- Comment #5 from Adam Ryan  ---
Hi Andrew, is that the test case you want to go into the patch? I had thought
since that the test case would be better with parameter pack containing
function references as the current one only compiles from c++20. I was going to
suggest it for a V2 patch but I haven't seen any interest in the submission so
far.