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

            Bug ID: 104652
           Summary: It's impossible to declare non-default target function
                    as a friend.
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vorfeed.canal at gmail dot com
  Target Milestone: ---

The following example generates error with GCC 11.2 and trunk:
https://godbolt.org/z/MKo9Whsf5

class Foo {
  public:
    explicit Foo(int f) : x(f) {}
    friend inline Foo bar(Foo&);
  private:
    int x;
};

[[gnu::target("default")]] inline Foo bar(Foo& foo) {
    return Foo(foo.x);
}

[[gnu::target("sse4.2")]] inline Foo bar(Foo& foo) {
    return Foo(foo.x);
}

default-target function is friend while SSE4.2-function is not. And it doesn't
look like there are a way to declare it as friend.
  • [Bug c++/104652] New: It's imp... vorfeed.canal at gmail dot com via Gcc-bugs

Reply via email to