Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Dmitry_Vyukov
Valued Contributor I
91 Views

Lmbda-related error

[bash]struct X
{
    X() {}
    X(X const& obj) {}
    ~X() {}
    void operator = (X const&) {}
    void exec() const {}
};

template
void exec(T f)
{
    f();
}

int main()
{
    X t;
    exec([=](){t.exec();});
}

[/bash]

In Win32 configuration compiles successfully, but in x64 configuration I get the following error:

Compiling with Intel C++ Compiler 11.1.071 [IA-32]... (Intel C++ Environment)

.\\lambda_bug.cpp(55): error: class "X" has no suitable copy constructor
X t;
^
detected during implicit generation of "__lambda1::(const X &)" at line 56

0 Kudos
9 Replies
Milind_Kulkarni__Int
New Contributor II
91 Views

Looks like you are using Composer Update3.

Please check whether works . For me, its working on Intel64 though withC++ Pro 11.1.054 . I did not check for Composer. If still does not work, it should be compiler bug, and should be escalated.

Dmitry_Vyukov
Valued Contributor I
91 Views

Of course I set Enable C++0x Support = Yes (/Qstd=c++0x) before working with lambdas. And yes, it's Parallel Studio SP1.

jimdempseyatthecove
Black Belt
91 Views

Also error message is wrong

\lambda_bug.cpp(55): error: class "X" has no suitable copy constructor
X t;
^
detected during implicit generation of "__lambda1::(const X &)" at line 56

Should read

... "__lambda1::(const volatile X &)" at line 56

The incorrect error message had me blank staring at code for several hours.

Jim Dempsey

jimdempseyatthecove
Black Belt
91 Views

Jennifer,

Additional info.

I added to my copy constructor a defensive validator and code to correct the errant input arg should it fail verification (and verify assumed corrected reference, _ASSERT if uncorrectable).

However, now instead of calling

T(const volatile T& ref);

The compiler is calling

T(volatile T& ref);

The code I added can be conditionalized in or out. Excepting for line breaks and (conditionalize out code). The new copy of the code "should" compile the same as yesterdays code. But it does not.

My guess is the compiler is using Lambda functions and a reference to a token is getting screwed-up. The junk being used for the token is flipping the choice of copy constructors.

Jim Dempsey

Brandon_H_Intel
Employee
91 Views

I can reproduce the problem with Intel Parallel Composer both update 3 and update 5. Curiously, there is no problem with 11.1 pro. You're likely right, Jim, but let me investigate further to confirm the problem, and I'llupdate this thread on my status.
Brandon_H_Intel
Employee
91 Views

Ok, so it turns out I can reproduce this with 11.1 pro, but only with the 32-bit hosted compiler targeting Intel 64 architecture. Really odd issue, but I've reported this to our front-end team, and I will keep you up to date on their status here. How blocked are you guys on this issue? I've got it set with a customer impact of High (which is to quickly summarize "I can survive for now, but fix asap please"), but I can bump it up to Showstopper (i.e. "I can't do anything with your compiler until this is fixed") if necessary.
jimdempseyatthecove
Black Belt
91 Views

Brandon,

It is not a show stopper for me since I've written code to on-the-fly fix the error (when error present). A little slower execution. I've just downloaded the Parallel Composer update 5, but haven't installed. I do not know if this problem is present or not in update 5.

Jim Dempsey

Brandon_H_Intel
Employee
91 Views

I've reproduced the problem on update 5 as well.

A workaround suggested by our front-end team is to use a reference lambda instead of copying i.e.:

[cpp]exec([&](){t.exec();});[/cpp]

We are lookinginto fixing this for the next major compiler version. If a fix in 11.1 or the current Intel Parallel Composer is needed, let me know.

Brandon_H_Intel
Employee
91 Views

Hi all,

This issue is resolved in the 12.0 compiler that's part of Intel Parallel Composer 2011 and Composer XE 2011 products. Let us know if there's any problems.
Reply