steffenlarsen wrote:
> This seems unnecessarily pessimistic. `llvm::emitAMDGPUPrintfCall()` was
> designed with the intention of simply printing a pointer when it's not clear
> that a given argument actually points to a string corresponding to a `%s`
> specifier. `printf` is a generally useful function for debugging, so it was
> deemed the users responsibility if they don't see the string argument they
> expected. The general message is, "don't do fancy stuff, there are
> limitations to what you will see, but we will be lenient in what we accept".
Do we make it clear that it is the case that "%s" only currently works if the
format string can be determined at compile-time? They way it is currently
implemented, it's very easy for a user to go from printing a string through
"%s" in a way that works to a way that doesn't work. I agree that this solution
is pessimistic, as we cannot determine if a "%s" is inside the format string,
but AFAICT the only valid case this should break is when a user wants to print
the address of a pointer ("%p" or any integer format), but for users running
into this restriction it should be easy to work around it by casting the
pointer to an appropriate integer type. As such, I would argue that we pay a
small cost to prevent the user shooting themselves in the foot.
https://github.com/llvm/llvm-project/pull/238287
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits