在 5/4/21 8:31 AM, Peng Yu via Gcc-help 写道:
In the following example, printf() is converted to puts(). What are the options to turn off any possible optimization during compilation and just let gcc literally translate the C code to the assembly code? Note that clang does not perform such an optimization. Should gcc do the same to turn off any optimization by default? Thanks.
This is because GCC assumes the effects are equivalent, and such assumption is valid because you are calling `printf()` and `puts()` from the standard library.
In order to prevent this, pass `-fno-builtin-printf` so GCC no longer considers `printf()` as something it already knows. You may even pass `-fno-builtin` or `-ffreestanding` to make GCC forget all such functions, including `memcpy()` and `memset()`.
-- Best regards, Liu Hao
Attachment:
OpenPGP_signature
Description: OpenPGP digital signature