Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Calling wrong lambda

MarcusGustafsson
Beginner
2,160 Views

Seems like a bug to me: https://godbolt.org/z/rxY7Wh8x7

Attaching files as well.

Adding static to the functions called hidden avoids the problem.

 

To elaborate a bit:

 

A function foo taking a lambda or a std::function.

In file1: A function called hidden in a anonymous namespace calling foo. 

Also in file 1: A function called apa::run_file1 that calls hidden();

 

In file2: A function called hidden in a anonymous namespace calling foo. 

Also in file 2: A function called apa::run_file2 that calls hidden();

 

Main function calls:

apa::run_file1() and apa::run_file2().

 

When building and running with ICC the lambda used in file1.cpp:hidden is also used when calling apa::run_file2. Seems like nameless lambdas in unnamed namespaces can get the same symbol name when defined in functions with identical signatures.

 

Best Regards

Marcus

Labels (1)
0 Kudos
1 Solution
MWind2
New Contributor III
1,930 Views

When I build and run on Linux(Mint 22.04) and Windows, both 64 bit, I get correct result 2021.4.0

View solution in original post

0 Kudos
7 Replies
NoorjahanSk_Intel
Moderator
2,114 Views

Hi,


Thanks for reaching out to us.

Could you please try compiling your code with the Intel icpx compiler? It compiled successfully from our end with icpx compiler.

Please do let us know if you face any issues.


Thanks & Regards,

Noorjahan.


0 Kudos
MarcusGustafsson
Beginner
2,101 Views

Noorjahan,

 

I work in a locked down environment so I'll see what I can do regarding testing icpx. That is also why I supplied the Compiler Explorer link.

Also you state that you compile successfully, what about the runtime result? Is the correct lambda called? Please also test the latest version of the classic C++ compiler and let me know the result.

 

Best regards

Marcus

 

0 Kudos
MarcusGustafsson
Beginner
2,072 Views

Hi all,

 

here is an update:

 

I've downloaded the intel/oneapi-hpckit Docker image and tested:

[icc-bug]$ icc --version
icc (ICC) 2021.4.0 20210910
Copyright (C) 1985-2021 Intel Corporation.  All rights reserved.

[icc-bug]$ icpx --version
Intel(R) oneAPI DPC++/C++ Compiler 2021.4.0 (2021.4.0.20210924)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/intel/oneapi/compiler/2021.4.0/linux/bin

And the results:

Output from ICC:
./icc-test
This is the hidden function in file1.cpp saying Hello!
This is the hidden function in file1.cpp saying Hello!
---------------------------------------------------------------------
Output from ICPX:
./icpx-test
This is the hidden function in file1.cpp saying Hello!
This is the hidden function in file2.cpp saying Hello!

I.e. newest ICC shows the bug and newest ICPX works correctly. Can one expect ICC to be patched?

 

Br

Marcus

0 Kudos
NoorjahanSk_Intel
Moderator
1,975 Views

Hi,

 

Thank you very much for reporting the issue.

 

>> what about the runtime result? Is the correct lambda called?

 

Apologies for the incomplete information.

 

We are also able to see the incorrect result with the latest ICC version, Whereas with the latest icpx we are getting the correct result i.e. correct lambda is called as you have mentioned in the previous post.

 

Please find the attached screenshots for more details.

 

>>Can one expect ICC to be patched?

 

We have reported this issue to the development team, they are looking into this issue

 

 

Thanks & Regards,

Noorjahan.

 

0 Kudos
Viet_H_Intel
Moderator
1,948 Views

Hi Marcus,


Since this issue is only seen with icpc and there is a workaround by having void hidden() in file2.cpp as static.

At some point in the future, the classic C/C++ compilers will enter “Legacy Product Support” mode signaling the end of regular updates to the classic compiler base, and they will no longer appear in oneAPI toolkits.

Please see this article for more details. https://www.intel.com/content/www/us/en/developer/articles/technical/adoption-of-llvm-complete-icx.html.


I reported this issue to our Developer but unsure if it will be fixed in icpc as the article mentioned. Hence, my recommendation is to migrate your code to icpx.


Thanks,




0 Kudos
MWind2
New Contributor III
1,931 Views

When I build and run on Linux(Mint 22.04) and Windows, both 64 bit, I get correct result 2021.4.0

0 Kudos
Devorah_H_Intel
Moderator
1,256 Views

Fix is coming in the next 2022.3 oneAPI Toolkits release.

0 Kudos
Reply