public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104995] New: access checking for function pointer template parameters takes place at call site
@ 2022-03-21  1:03 mawww at kakoune dot org
  2022-03-21  1:12 ` [Bug c++/104995] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: mawww at kakoune dot org @ 2022-03-21  1:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104995
           Summary: access checking for function pointer template
                    parameters takes place at call site
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mawww at kakoune dot org
  Target Milestone: ---

The following code

```
template<auto F>
void func() {
    auto lambda = [&](auto&& s) { F(s); };
    lambda(0);
}

struct S {
    void f() { func<S::g>(); }

private:
    static void g(int) {}
};
```

Fails to compile on g++ 11.2.1 with the following error:

```
test.cc: In instantiation of ‘func<S::g>()::<lambda(auto:1&&)> [with auto:1 =
int]’:
test.cc:4:11:   required from ‘void func() [with auto F = S::g]’
test.cc:8:26:   required from here
test.cc:3:36: error: ‘static void S::g(int)’ is private within this context
    3 |     auto lambda = [&](auto&& s) { F(s); };
      |                                   ~^~~
test.cc:11:17: note: declared private here
   11 |     static void g(int) {}
      |                 ^

```

Clang accepts this code, making func's body just `{ F(0); }` compiles without
errors as well.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-22 14:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-21  1:03 [Bug c++/104995] New: access checking for function pointer template parameters takes place at call site mawww at kakoune dot org
2022-03-21  1:12 ` [Bug c++/104995] " pinskia at gcc dot gnu.org
2023-01-03 18:07 ` [Bug c++/104995] access checking for function pointer template parameters takes place at call site inside a lambda pinskia at gcc dot gnu.org
2023-03-25 14:43 ` [Bug c++/104995] [10/11/12/13 Regression] access checking for function pointer template parameters takes place at call site inside a templated (generic) lambda ppalka at gcc dot gnu.org
2023-07-07 10:42 ` [Bug c++/104995] [11/12/13/14 " rguenth at gcc dot gnu.org
2024-03-22 14:06 ` law at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).