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

            Bug ID: 122630
           Summary: Function parameter conversion is broken when
                    dereferencing a function/pointer-to-function
           Product: gcc
           Version: 15.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jengelh at inai dot de
  Target Milestone: ---

== Input ==

#include <span>
extern void f();
extern void g1(std::span<const int>);
extern void (*g2)(std::span<const int>);
void f()
{
        int num[] = {2, 17, 18, 19};
        g1(num);
        (*g1)(num);
        (*g2)(num);
}

== Observed output ==

The line with (*g1) and (*g2) fail to compile.

$ g++-15 -std=c++20 -c 2.cpp
2.cpp: In function ‘void f()’:
2.cpp:9:15: error: could not convert ‘(int*)(& num)’ from ‘int*’ to
‘std::span<const int>’
    9 |         (*g1)(num);
      |               ^~~
2.cpp:10:15: error: could not convert ‘(int*)(& num)’ from ‘int*’ to
‘std::span<const int>’
   10 |         (*g2)(num);
      |               ^~~

== Expected output ==

Do not fail. clang++-16/19/21-with-gnustdlibc++ succeed.

Reply via email to