public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95127] New: Self-calling lambda with auto return type gives misleading error message
@ 2020-05-14 10:41 xzlsmc at gmail dot com
  2020-05-14 10:48 ` [Bug c++/95127] " xzlsmc at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: xzlsmc at gmail dot com @ 2020-05-14 10:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95127
           Summary: Self-calling lambda with auto return type gives
                    misleading error message
           Product: gcc
           Version: 9.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xzlsmc at gmail dot com
  Target Milestone: ---

$ cat bug.cc
int main() {
  auto f = [](const auto &g, auto x) { return g(g, x); };
  f(f, 0);
}
$ gcc -std=c++14 bug.cc
bug.cc: In instantiation of ‘main()::<lambda(const auto:1&, auto:2)> [with
auto:1 = main()::<lambda(const auto:1&, auto:2)>; auto:2 = int]’:
bug.cc:3:9:   required from here
bug.cc:2:48: error: use of ‘main()::<lambda(const auto:1&, auto:2)> [with
auto:1 = main()::<lambda(const auto:1&, auto:2)>; auto:2 = int]’ before
deduction of ‘auto’
    2 |   auto f = [](const auto &g, auto x) { return g(g, x); };
      |                                               ~^~~~~~

This error message is technically correct, but the `auto' it refers to is very
misleading here: it's the implicit `auto' return type of the lambda expression,
rather than either `auto' argument type.  The message can become clearer if
changed to "use of ... before deduction of _return type_".

GCC version: 9.3.1

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

end of thread, other threads:[~2021-09-02  1:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-14 10:41 [Bug c++/95127] New: Self-calling lambda with auto return type gives misleading error message xzlsmc at gmail dot com
2020-05-14 10:48 ` [Bug c++/95127] " xzlsmc at gmail dot com
2021-08-07  1:43 ` pinskia at gcc dot gnu.org
2021-09-02  1:22 ` egallager at gcc dot gnu.org
2021-09-02  1:26 ` pinskia 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).