public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53488] New: Incorrect code generated when capturing a constant by reference in a lambda
@ 2012-05-25 16:07 jpalecek at web dot de
  2012-05-25 16:18 ` [Bug c++/53488] " redi at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: jpalecek at web dot de @ 2012-05-25 16:07 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53488

             Bug #: 53488
           Summary: Incorrect code generated when capturing a constant by
                    reference in a lambda
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jpalecek@web.de


Created attachment 27497
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27497
Preprocessed source

I have the following source:

jirka@debian:~/benchmark$ cat error.cpp 
#include <iostream>

template<class T>
void f()
{
  const int i=sizeof(T);
  auto fun = [&] { std::cout << i << std::endl; };
  fun();
}

int main()
{
  f<double>();
  return 0;
}

When I compile and run this program, it outputs garbage (instead of
sizeof(double)):

jirka@debian:~/benchmark$ g++-4.7 --std=c++0x error.cpp
jirka@debian:~/benchmark$ ./a.out 
134514706

Changing f to a nontemplate, i to be nondependent ot captured by value produces
correct output.


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

end of thread, other threads:[~2012-08-19 14:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-25 16:07 [Bug c++/53488] New: Incorrect code generated when capturing a constant by reference in a lambda jpalecek at web dot de
2012-05-25 16:18 ` [Bug c++/53488] " redi at gcc dot gnu.org
2012-05-25 17:55 ` jpalecek at web dot de
2012-05-25 20:11 ` daniel.kruegler at googlemail dot com
2012-06-24 14:21 ` lunow at math dot hu-berlin.de
2012-06-24 14:30 ` lunow at math dot hu-berlin.de
2012-06-24 20:12 ` jpalecek at web dot de
2012-06-24 20:23 ` jpalecek at web dot de
2012-06-25  0:32 ` lunow at math dot hu-berlin.de
2012-06-25 14:28 ` ai.azuma at gmail dot com
2012-08-19 14:04 ` jpalecek at web dot de
2012-08-19 14:11 ` jpalecek at web dot de

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).