https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47781

--- Comment #33 from David Crocker <dcrocker at eschertech dot com> ---
I have another use case for this. We have several projects using Arm Cortex M4F
MCUs. As this processor has single-precision floating point hardware only, we
use float everywhere, never double. We have our own implementation of printf
and friends. Every time we want to pass a float to printf it gets converted to
double, which is expensive in code size and execution time. So I want to use
std::bit_cast to convert each float argument to e.g. uint32_t to pass to printf
and then use a custom format specifier within our printf implementation. I
tried supporting it using the 'h' modifier (e.g. %hf) but gcc gives a format
error warning that modifier 'h' is not supported with format specifier 'f'. The
%p trick doesn't work because %.1pf gives a warning that format specifier 'p'
cannot have a precision modifier. Short of disabling all format warnings, I
haven't found a solution.

Reply via email to