public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/95359] New: Failure to optimize printfs with extraneous arguments
@ 2020-05-27  7:34 gabravier at gmail dot com
  2020-05-27 12:05 ` [Bug tree-optimization/95359] " marxin at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: gabravier at gmail dot com @ 2020-05-27  7:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95359
           Summary: Failure to optimize printfs with extraneous arguments
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

void f()
{
    printf("", 2);
}

This can be optimized to doing nothing (the extraneous arguments should be
ignored and just evaluated by themselves, it's not UB). This transformation is
done by LLVM, but not by GCC.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug tree-optimization/95359] Failure to optimize printfs with extraneous arguments
  2020-05-27  7:34 [Bug tree-optimization/95359] New: Failure to optimize printfs with extraneous arguments gabravier at gmail dot com
@ 2020-05-27 12:05 ` marxin at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-05-27 12:05 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org
   Last reconfirmed|                            |2020-05-27
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |WAITING

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
With GCC you see:

gcc pr95359.c -c -O2 -Wall -Wextra
pr95359.c: In function ‘f’:
pr95359.c:3:22: warning: zero-length gnu_printf format string
[-Wformat-zero-length]
    3 |     __builtin_printf("", 2);
      |                      ^~

or:

gcc pr95359.c -c -O2 -Wall -Wextra
pr95359.c: In function ‘f’:
pr95359.c:3:22: warning: too many arguments for format [-Wformat-extra-args]
    3 |     __builtin_printf("aa", 2);
      |                      ^~~~

Does it really worth doing an optimization?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-27 12:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27  7:34 [Bug tree-optimization/95359] New: Failure to optimize printfs with extraneous arguments gabravier at gmail dot com
2020-05-27 12:05 ` [Bug tree-optimization/95359] " marxin at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).