https://llvm.org/bugs/show_bug.cgi?id=24077
Bug ID: 24077
Summary: Corrupted member initialization via initialization
list when in a lambda nested in a templated function
Product: clang
Version: 3.6
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
A simple class member initialization from a ctor parameter in a ctor
initialization list results in an incorrect value for that member. Doing the
initialization in the constructor body works. Tested with clang 3.4, 3.5 and
3.6 (3.6 installed from this site) on Ubuntu.
Code:
#include <stdio.h>
#include <functional>
typedef void(*cfunc_t)(void*);
template <class F>
void test(F&& f)
{
struct Msg
{
F func;
cfunc_t cfunc;
Msg(cfunc_t aCfunc, F&& aFunc)
:cfunc(aCfunc), func(std::forward<F>(aFunc)){}
};
Msg msg([](void* ptr)
{
struct Test
{
Msg* mMsg;
Test(Msg* aMsg): mMsg(aMsg) // <=== BUG: mMsg has a corrupted
value!
{ printf("aMsg = %p, mMsg = %p\n", aMsg, this->mMsg);}
};
Test t(static_cast<Msg*>(ptr));
}, std::forward<F>(f));
msg.cfunc(nullptr);
}
int main()
{
test([](){});
}
===================
Output:
aMsg = (nil), mMsg = 0x4006b5
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs