[Bug 1950053] Re: Friend function with requires causes segfault

Matthias Klose 1950053 at bugs.launchpad.net
Mon Sep 4 07:59:57 UTC 2023


this works with gcc-11 on Ubuntu 22.04 LTS


** Changed in: gcc-11 (Ubuntu)
       Status: New => Fix Released

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-11 in Ubuntu.
https://bugs.launchpad.net/bugs/1950053

Title:
  Friend function with requires causes segfault

Status in gcc-11 package in Ubuntu:
  Fix Released

Bug description:
  From the versions installed on my machine, the bug occurs in g++
  10.2.0, g++ 10.3.0 and g++ 11.1.0, the only argument in -std=c++2a.
  The code works on version 9.3.0 with -std=c++2a and -fconcepts. I have
  also compiled with clang++ 12.0.0 without problems. The bug occurs
  when two or more classes declare a template friend function with a
  requires. The return type, number of arguments, number of template
  parameters, and condition for requires does not make any
  difference.Example:

  class Foo
      {
          template <typename T>
          friend void func() requires true;
      };
      class Bar
      {
          template <typename T>
          friend void func() requires true;
      };

  This code results in the following error message:

  internal compiler error: Segmentation fault
      9 |         friend void func() requires true;
        |                                     ^~~~
  0xe30681 internal_error(char const*, ...)
          ???:0
  0xf54144 duplicate_decls(tree_node*, tree_node*, bool, bool)
          ???:0
  0xf5da9b pushdecl_namespace_level(tree_node*, bool)
          ???:0
  0x109001a push_template_decl(tree_node*, bool)
          ???:0
  0x151d391 do_friend(tree_node*, tree_node*, tree_node*, tree_node*, overload_flags, bool)
          ???:0
  0xfbfc27 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*, decl_context, int, tree_node**)
          ???:0
  0x1003fd4 grokfield(cp_declarator const*, cp_decl_specifier_seq*, tree_node*, bool, tree_node*, tree_node*)
          ???:0
  0x1492c03 c_parse_file()
          ???:0
  0x148061e c_common_parse_file()
          ???:0
  Please submit a full bug report,
  with preprocessed source if appropriate.
  Please include the complete backtrace with any bug report.
  See <file:///usr/share/doc/gcc-11/README.Bugs> for instructions.

  On g++-10.x the error is only

  internal compiler error: Segmentation fault
      9 |         friend void func() requires true;
        |                                     ^~~~
  Please submit a full bug report,
  with preprocessed source if appropriate.
  See <file:///usr/share/doc/gcc-10/README.Bugs> for instructions.

  
  Whether the function actually exists does not have any impact. The error message always points to the second definition, in this case Bar.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-11/+bug/1950053/+subscriptions




More information about the foundations-bugs mailing list