zygoloid wrote:

I found this: 
https://fuchsia.googlesource.com/third_party/github.com/fmtlib/fmt/+/refs/heads/upstream/main/include/fmt/base.h#2664

Note that this is passing `s` separately both to `parse_format_string` and to 
`checker`. Here, `s` is a lambda that implicitly converts to a string view by 
evaluating a string literal. Those two evaluations can return different string 
literal objects, and I'm assuming pointers to those strings are what we end up 
subtracting.

So yes, this fmtlib code is wrong -- it's incorrectly assuming that a string 
literal will always evaluate to the same value, which is not true at runtime or 
(after this Clang change) at compile time. The correct thing to do would be 
what is done a few lines below in the next constructor: convert the `S` object 
to a string view once, and then use that same value for both calls.

https://github.com/llvm/llvm-project/pull/109208
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to