public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97256] New: auto function return different result
@ 2020-09-30 14:08 tangyixuan at mail dot dlut.edu.cn
  2020-09-30 15:00 ` [Bug c++/97256] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: tangyixuan at mail dot dlut.edu.cn @ 2020-09-30 14:08 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97256
           Summary: auto function return different result
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tangyixuan at mail dot dlut.edu.cn
  Target Milestone: ---

Hi, when executing the following code, GCC reports 32765 while clang reports 1. 
Maybe there is something wrong?
$ cat s.cpp

#include <iostream>
auto func(const int a) {
  const int b = a;
  return [&](){ return b; };
}


int main() {
  auto c = func(1);
  std::cout << c() ;
  return 0;
}

$ g++ -std=c++2a s.cpp
$ ./a.out
32765


$ clang++ -std=c++2a s.cpp
$ ./a.out
1

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

end of thread, other threads:[~2020-10-02 13:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-30 14:08 [Bug c++/97256] New: auto function return different result tangyixuan at mail dot dlut.edu.cn
2020-09-30 15:00 ` [Bug c++/97256] " rguenth at gcc dot gnu.org
2020-10-01 10:01 ` redi at gcc dot gnu.org
2020-10-01 10:01 ` redi at gcc dot gnu.org
2020-10-02  1:00 ` richard-gccbugzilla at metafoo dot co.uk
2020-10-02  1:04 ` mpolacek at gcc dot gnu.org
2020-10-02  4:50 ` richard-gccbugzilla at metafoo dot co.uk
2020-10-02 13:32 ` redi 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).