public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54170] New: Call to lambda elided
@ 2012-08-04  0:03 bekenn at yopmail dot com
  2012-08-04  0:07 ` [Bug c++/54170] " paolo.carlini at oracle dot com
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: bekenn at yopmail dot com @ 2012-08-04  0:03 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 54170
           Summary: Call to lambda elided
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: bekenn@yopmail.com


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

gcc version: 4.7.0
target: mingw32
Configured with: ../gcc-4.7.0/configure
--enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions
--with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry
--enable-libstdcxx-debug --disable-build-poststage1-with-cxx
--enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
command line: gcc -v -save-temps -std=gnu++0x -c -g src\lambdatest.cpp
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=gnu++11' '-c' '-g' '-mtune=i386'
'-march=i386'

lambdatest.cpp:
#include <utility> // for std::forward

// externally defined
void ExternalFunction1(const char*, int);
void ExternalFunction2(int, void**);

template <class Callable, typename... ArgTypes>
void* Call(Callable native_func, ArgTypes&&... args) noexcept
{
    return native_func(std::forward<ArgTypes>(args)...);
}

void* test_lambda(void* functionData, int argc, void* argv[])
{
    return Call([=]
    {
        ExternalFunction1("Lalala...", 0);
        ExternalFunction2(argc, argv);
        return nullptr;
    });
}


---

This compiles without error messages, but gives incorrect output.  The call to
native_func on line 10 is left out, and Call simply returns 0 instead.  This
can be verified by examining the generated assembly:

__Z4CallIZ11test_lambdaPviPS0_EUlvE_IEES0_T_DpOT0_:
    pushl    %ebp
    movl    %esp, %ebp
    movl    $0, %eax
    popl    %ebp
    ret

No code is generated for the lambda body, and the resulting object file does
not contain references to ExternalFunction1 or ExternalFunction2.


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

end of thread, other threads:[~2014-05-24 12:11 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-04  0:03 [Bug c++/54170] New: Call to lambda elided bekenn at yopmail dot com
2012-08-04  0:07 ` [Bug c++/54170] " paolo.carlini at oracle dot com
2012-08-04 10:48 ` redi at gcc dot gnu.org
2012-08-04 11:35 ` paolo.carlini at oracle dot com
2012-08-04 11:37 ` paolo.carlini at oracle dot com
2012-08-06  4:44 ` bekenn at yopmail dot com
2012-08-06  4:46 ` bekenn at yopmail dot com
2012-08-06  7:52 ` redi at gcc dot gnu.org
2012-08-06  8:11 ` bekenn at yopmail dot com
2012-08-06  8:32 ` redi at gcc dot gnu.org
2012-11-30 12:31 ` paolo.carlini at oracle dot com
2012-12-03 16:02 ` paolo at gcc dot gnu.org
2012-12-03 16:10 ` paolo.carlini at oracle dot com
2013-07-10  2:57 ` foom at fuhm dot net
2013-07-10  5:14 ` jason at gcc dot gnu.org
2013-07-10  5:54 ` jason at gcc dot gnu.org
2014-05-24 12:11 ` 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).