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

support of std::source_location

Daniel_D
Beginner
805 Views

Hi,

 

do you have any plans to support std::source_location? It is part of C++ 20.

My project compiles fine if I use the MS include for it (#include <source_location>), but it does not work as expected.

 

Thanks,

Daniel

 

 

0 Kudos
5 Replies
RabiyaSK_Intel
Moderator
762 Views

Hi,

 

Thanks for posting in Intel Communities.

 

Could you please provide a sample reproducer code and steps to reproduce it along with your

  1. Intel oneAPI Toolkits Version
  2. OS and hardware details
  3. Actual and Expected Output

 

Thanks & Regards,

Shaik Rabiya

 

 

0 Kudos
Daniel_D
Beginner
752 Views

Hi Shaik,

 

Sure - here some information of my system:

 

Windows 11 - all updates,

VS2022 

Intel C++ 2023

Intel CPU (I do not think that the CPU matters here)

Since source_location is a C++20 feature I enable C++20 Standard (/std:c++20)

 

Here is the sample:

#include <source_location>

void TestCall(const std::source_location& p_SourceLocation = std::source_location::current())
{
   printf("File = %s\n", p_SourceLocation.file_name());
   printf("Line = %u\n", p_SourceLocation.line());
}

int main()
{
   TestCall();
}

 

Output with MS compiler - matches the expectations:

File = C:\Users\test\source\repos\ConsoleApplication5\ConsoleApplication5.cpp
Line = 21

 

Output with Intel C++ 2023 compiler - look like it uses just the __LINE__ and __FILE__ macros:

File = ConsoleApplication5.cpp
Line = 11

 

The Intel compiler cannot compile the source as it is because there seems to be some issues with the include file foe source_location. Without modification you will get:
14:15:53:600 1> ConsoleApplication5.cpp(9,26): : error : no type named 'source_location' in namespace 'std'
14:15:53:600 1> void TestCall(const std::source_location& p_SourceLocation = std::source_location::current())
14:15:53:600 1> ~~~~~^
14:15:53:600 1> ConsoleApplication5.cpp(9,67): : error : no member named 'source_location' in namespace 'std'
14:15:53:600 1> void TestCall(const std::source_location& p_SourceLocation = std::source_location::current())

adding this line will fix that:
#define __cpp_consteval 201811L
#include <source_location>

 

Let me know if you need more information.

 

0 Kudos
RabiyaSK_Intel
Moderator
706 Views

Hi,


We are able to reproduce your issue. We have informed the development team about it. We will get back to you soon.


Thanks & Regards,

Shaik Rabiya


0 Kudos
RabiyaSK_Intel
Moderator
639 Views

Hi,


Thanks for your patience. This issue will be fixed in 2023.2 oneAPI version which will be released soon. If the issue still persists with new release, then you can start a new discussion for the community to investigate.


Thanks & Regards,

Shaik Rabiya


0 Kudos
Daniel_D
Beginner
581 Views

Hi - any ETA for 2023.2?

 

Thanks.

0 Kudos
Reply