riscv-collab / riscv-gnu-toolchain

GNU toolchain for RISC-V, including GCC
Other
3.56k stars 1.17k forks source link

Toolchain doesn't support "Format specifier like %g" in printf #1621

Open RRArinc opened 2 days ago

RRArinc commented 2 days ago

Hi, I build the toolchain GCC13 version and able to compile the sample c code as below and observed the following.

// program to printf fixed and float point values

include

int main() { printf( "hello -%g- world -%f-\n", 1.0, 1.0f); return 0; }

Any online GCC compiler provides output as hello -1- world -1.000000-

However riscv32-unknown-elf-gcc compiles and outputs as hello -g- world -1.000000-

Here format specifier %g representing "fixed point" value is not printed correctly, but only prints "floating point" values.

Note: Toolchain is build for bare metal and not Linux flavour.

Any inputs/suggestions are welcome.

Thanks

TommyMurphyTM1234 commented 2 days ago

Works for me using the most recent GCC 13.2 CI build: