Consider the template function g()
and free function f()
:
#include <iostream>
#include <source_location>
auto g(auto...) {
std::cout << std::source_location::current().column() << "\n";
}
auto f() {
std::cout << std::source_location::current().column() << "\n";
}
int main() {
g();
f();
}
Compiled with GCC-trunk get following output:
43
44
Why g()
and f()
yield different results? I expect the results are the same. Why a unit offset disappeared during the instantiation of the template?
I file a PR 99672 to GCC Bugzilla. Jakub Jelinek (one of the GCC contributor) reply me:
I think the standard doesn't specify anything about what exactly the column should be, so using different columns isn't standard violation.
but he still did a patch to fix it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With