This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: patch to suggest putc/fputs over printf("string") or printf("\n")
- To: egcs-patches at cygnus dot com, egcs at cygnus dot com, ghazi at caip dot rutgers dot edu
- Subject: Re: patch to suggest putc/fputs over printf("string") or printf("\n")
- From: mrs at wrs dot com (Mike Stump)
- Date: Mon, 11 Jan 1999 11:43:32 -0800
> Date: Sun, 10 Jan 1999 02:18:40 -0500 (EST)
> From: "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu>
> To: egcs-patches@cygnus.com, egcs@cygnus.com
> Do people think that the warnings appearing below would be useful?
> cccp.c:1635: warning: suggest using `putc' instead of `fprintf'
> cccp.c:2058: warning: suggest using `fputs' instead of `fprintf'
> cccp.c:10232: warning: suggest using `strcpy' instead of `sprintf'
No, I don't like these at all. I think it would be more useful to fix
the compiler to transform the printf call into a putc call, the hard
thing about it is you really want to do this early so that you can get
at the marcos, if any. Anyway, even if one didn't, I think it would
still be useful.
The reasoning behind not liking these, is it unduly encourages people
to save five clock cycles at the expense of readable code. If it goes
in, please don't have it on by default or -Wall.
Yes folk, this optimization is allowed, at least in C++. :-)