<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/56580>56580</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Unexpected evaluation-point of std::souce_location::current()
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          aasimon
      </td>
    </tr>
</table>

<pre>
    Consider three files: log.h, log.cc and main.cc

log.h:
```
#pragma once

#include <string>
#include <source_location>

void log(const std::string& message,
         const std::source_location location = std::source_location::current());
````

log.cc:
```
#include "log.h"

#include <iostream>

void log(const std::string& message,
         const std::source_location location)
{
  std::cout << message << " " << location.file_name() << ":" << location.line() << '\n';
}
```

and main.cc:
```
#include "log.h"

int main()
{
  log("hello");
}
```

Compiling with latest clang++-15 trunk:
```
$ clang++-15 --version
Debian clang version 15.0.0-++20220715100655+5e0443292bf0-1~exp1~20220715220804.622
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
```

```
$ clang++-15 -std=c++20 log.cc main.cc -o test
```

Running is expected to give the result "hello main.cc:5" (which is the case for g++-11) but in fact gives:
```
$ ./test
hello ./log.h:7
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFVEuPmzAQ_jVwsUDGvJIDh02yK_VateeVMQO4NXZkm2z672vzyGbTTVT10sgx2PP65pthatX8qvZKGt6ARrbXAKjlAkyQPiGhurgPyH56YQxR2aCBcuneA3wI8NO8z2rpcgoKvKz5SNKjpt1AkZIMrs2chEsmxgZQkO6N1Vx2Qfr8qVCNmsGrUIxaruS71rSfFG88xIBsmMvEImMbDyd9WpySAg1gDO3AJTPboPV3a_ExErq8BOnhrtZ8yUatQVqHIiBbv9LdLSMXUi68OSbvE3dhgJClFOQ-gVy5bIEO_4Ecn-wcstytHi5GTI3W43NrDbQeXT7zfz6u7mLfgK-SDjBzeaXuXX5iILj8Q7cM8r30j0sZysPnRE_7dW__c0W4tJOTpQduOZnL4Gx6EEJ52-sueQhvr4Yjd2l26I3bHglqwVWGCeoruHMrSnJk9Sh_3kef3epH0Qm08QWcNA5QcypnJbRIUJLHOMbRbEQwIbhM8gTjIs_dRQ44y1KyJXWLoyQon-F89I9V0e0bnMXFStM3qjuwfracN8VrkUVHFrmsxnPUyXFRcTOIulqoBoRXPCrDz7Poi-tGKgQ0B669KCAvo9Fur7l8wN1fEDF164GtWa4Db2kIFCnk-X4Q4-sopa8ON8hRAMxCg6xCHT-Bm6qANJhRWLTW_qrV8vkr2Lz1nPXe3qszatwcVhpdQCa-uWv3KXGJWsrs5No8KnbsiHlHPYf1d-u4Lm8sw6ZKm226paHlVkD1XV4ygRMV4_SpRUflm1y1H6bC41kYjlpUvbXHCS55catzTTzWMVODByRO6yM6avXDxXRHbszoEiQveZFvcNhXDWlZ2dZtiUuaNZiU26JISJvnFCDflEkoaA3CVEG-C_JDyKulCcsEZwTjOCVtljVFu21aRhlOggyDK4OIfeBY6S7U1YShHjvjhIIba96F1BjeSYDVPx1tr3RFqeGDkuEEt5qw_gY5uhK1">