public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97219] New: Generic lambda does not find function declaration from enclosing block scope
@ 2020-09-27 17:37 hstong at ca dot ibm.com
  2020-09-27 20:51 ` [Bug c++/97219] " nathan at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: hstong at ca dot ibm.com @ 2020-09-27 17:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97219
           Summary: Generic lambda does not find function declaration from
                    enclosing block scope
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid, rejects-valid, wrong-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hstong at ca dot ibm.com
  Target Milestone: ---

The unqualified lookup for `q` in the instantiation of the generic lambda
should resolve to the block-scope function declaration.
Such a lookup result should furthermore suppress argument dependent lookup.

GCC resolves `q` using argument dependent lookup at the point of instantiation
and chooses a worse candidate.

### SOURCE (<stdin>):
struct B;

template <typename T>
auto f(T *) {
  void q(B *, void * = static_cast<T *>(0));
  return [](auto *p) { q(p); };
}

void q(void *) = delete;

int main(void) {
  B *bp = 0;
  f(bp)(bp);
}


### COMPILER INVOCATION:
g++ -fsyntax-only -std=c++20 -Wall -Wextra -pedantic-errors -xc++ -


### ACTUAL OUTPUT:
<stdin>: In instantiation of 'f<B>::<lambda(auto:1*)> [with auto:1 = B]':
<stdin>:13:11:   required from here
<stdin>:6:25: error: use of deleted function 'void q(void*)'
<stdin>:9:6: note: declared here


### EXPECTED OUTPUT:
(clean compile)


### COMPILER VERSION INFO (g++ -v):
Using built-in specs.
COLLECT_GCC=/opt/wandbox/gcc-head/bin/g++
COLLECT_LTO_WRAPPER=/opt/wandbox/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../source/configure --prefix=/opt/wandbox/gcc-head
--enable-languages=c,c++ --disable-multilib --without-ppl --without-cloog-ppl
--enable-checking=release --disable-nls --enable-lto
LDFLAGS=-Wl,-rpath,/opt/wandbox/gcc-head/lib,-rpath,/opt/wandbox/gcc-head/lib64,-rpath,/opt/wandbox/gcc-head/lib32
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200925 (experimental) (GCC)

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

end of thread, other threads:[~2023-12-19 21:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-27 17:37 [Bug c++/97219] New: Generic lambda does not find function declaration from enclosing block scope hstong at ca dot ibm.com
2020-09-27 20:51 ` [Bug c++/97219] " nathan at gcc dot gnu.org
2021-11-29 21:12 ` [Bug c++/97219] [9/10/11/12 Regression] " ppalka at gcc dot gnu.org
2021-11-29 21:13 ` ppalka at gcc dot gnu.org
2022-01-17 15:06 ` rguenth at gcc dot gnu.org
2022-04-14  0:25 ` cvs-commit at gcc dot gnu.org
2022-04-14  0:25 ` [Bug c++/97219] [9/10/11 " jason at gcc dot gnu.org
2022-05-27  9:43 ` [Bug c++/97219] [10/11 " rguenth at gcc dot gnu.org
2022-06-28 10:42 ` jakub at gcc dot gnu.org
2023-07-07 10:38 ` [Bug c++/97219] [11 " rguenth at gcc dot gnu.org
2023-12-19 21:56 ` jason 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).