<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/98748>98748</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Unexpected std::source_location::file_name() result in combination with lambda and std::function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pkl97
</td>
</tr>
</table>
<pre>
This program returns
> File name: include/c++/v1/__type_traits/invoke.h
as file name when compiled with clang 17.0.6. I would have expected it to return main.cpp because the p_function() call is part of the program.
```c++
#include <iostream>
#include <functional>
#include <source_location>
void f(const std::function<void ()>& p_function)
{
p_function(); // std::source_location::file_name() resolves into include/c++/v1/__type_traits/invoke.h
}
int main()
{
const auto& lambda = [](const std::source_location& p_sourceLocation = std::source_location::current())
{
std::cout << "File name: " << p_sourceLocation.file_name() << std::endl;
};
f(lambda);
return 0;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVE2P4jgQ_TXOpdRRKAeSHHKApiOttMfdM3KcgnjbsSPbge1_v8oH0MDOSDPIMkq5XH7v1YfwXp0MUcnWO7beR2IIrXVl_6mLLKpt81X-1SoPvbMnJzpwFAZnPLBkz5LtsvMPqJQmMKIjxregjNRDQwwryXA3req8YlgdDuGrp0NwQgXPsFLmbD8pbr9HEx6O12BwacmAtF2vNDVwUaEFqYU5wSqLk3gTwx9wsYNuoBVnAvq3JxmoARUg2AUrdEKZWPY91CTF4AlCS9AfjoORQVnDMGdYgBRaw0hUuAD2ODvNpOMHsvO-SeZ1JThbkS_UgfF3ZX1wJDrGP_7v-Pq-0D9w8HZwkg7aSjHhvHlN-9mqBo4Mc2mND-BDw_iW8e2NFn-fXGZ642XcPLAulmjZAh4AXlRhfAcMK4bV_YEXWNOrStNhSv-spiNv9Zk8KBPsb9dDtv_OWJkw5XKB9oR-lkEMwY5EtejqRgDje5jr-lWoZx6TPLPxz8U23f85cTk4RyYsmK6wRi0fhB1_t0DSDmFMMOPvwBAfWochXo-e0cTPIi9-t7hkGs347juE_f17rJVZljmxd7elT5Kb8S78tcyjpuRNwQsRUbnKMMlz5GkRtSVmxzQRot5kcrNO62S9yQl5ionIs2OTUqRKTDBNshVfpWvEIq6TdZ2nXMgVX4s0aViaUCeUjrU-d7F1p0h5P1BZ5FmaR1rUpP00nBANXWA6ZIjjrHLleOetHk6epYlWPvh7lKCCpvJvcxsKv1zBgw6gpvFTKzMXxDSBluISpnltu2hwumxD6P1on1rnpEI71LG0HcNqhLf8vfXO_kMyjHU_khobYCZ9LvG_AAAA__9tTbFV">