[LLVMbugs] [Bug 24077] New: Corrupted member initialization via initialization list when in a lambda nested in a templated function
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Jul 9 11:29:25 PDT 2015
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: unassignedclangbugs at nondot.org
Reporter: avasilev at gmx.net
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150709/cae41b35/attachment.html>
More information about the llvm-bugs
mailing list