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: unassig...@gcc.gnu.org
        ReportedBy: bek...@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.

Reply via email to