On Fri, Oct 15, 2010 at 1:33 AM, Paolo Bonzini <pbonz...@redhat.com> wrote: > On 10/14/2010 07:59 PM, Blue Swirl wrote: >>> >>> It is even more hypothetical when empty-format printfs are optimized away >>> by >>> GCC: >>> >>> $ gcc -x c - -O2 -S -o - >>> #include<stdio.h> >>> main() { printf (""); } >>> >>> .file "" >>> .text >>> .p2align 4,,15 >>> .globl main >>> .type main, @function >>> main: >>> .LFB11: >>> .cfi_startproc >>> rep >>> ret >>> .cfi_endproc >>> >>> and other attribute-printf-marked functions are probably not noop when >>> the >>> format argument is empty. >> >> How is that? Does the warning message from qobject_from_json("") mean >> that GCC may optimize that call away? > > I meant, the warning is likely bogus for most functions that do "something > like printf" but it is not printf (like qobject_from_json, or asprintf). If > the only good reason to have the warning is a hypothetical performance > degradation, let's please turn it off, because this performance degradation > isn't even there.
Which functions are optimized away and which aren't? What would happen to for example monitor_printf("")? There are side effects, so it wouldn't be correct to remove a call like that, but those calls would still bring useless performance degradation.