[PATCH] D129488: [Sema] Delay evaluation of std::source_location::current() in default arguments
James Y Knight via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 31 08:42:11 PDT 2022
jyknight added a comment.
#include <stdio.h>
#include <source_location>
consteval int fn(std::source_location sl = std::source_location::current()) {
return sl.line();
}
consteval int fn2(int line = fn()) {
return line;
}
int main() {
printf("fn=%d fn2=%d\n", fn(), fn2());
}
I believe this should print `fn=14 fn2=14`. I don't see how we can get that by special-casing calls to `std::source_location::current`, and indeed, with this version of the patch, the program instead prints `fn=14 fn2=9`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129488/new/
https://reviews.llvm.org/D129488
More information about the cfe-commits
mailing list