https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116889
Bug ID: 116889
Summary: source_location line number off-by-one when implicitly
converting to a type with a defaulted source_location
argument
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: oliver.rosten at googlemail dot com
Target Milestone: ---
#include <iostream>
#include <source_location>
struct report{
report(const char*, std::source_location
loc=std::source_location::current()) {
std::cout << loc.line() << '\n';
}
};
void check(int, report r) {};
int main() {
check(42,
""); // Incorrectly reports line 20 (one above)
check(42,
report{""}); // Correctly reports line 24
}
https://godbolt.org/z/vz4Y4xanP