From: cgf@bbc.com (Chris Faylor)
To: gnu-win32@cygnus.com
Subject: Re: A TINY BUG
Date: Mon, 06 Oct 1997 18:01:00 -0000 [thread overview]
Message-ID: <EHnp1A.6qs@bbc.com> (raw)
In-Reply-To: <34391696.27758E19@softway.com>
In article < 34391696.27758E19@softway.com >,
Jason Zions <jazz@softway.com> wrote:
>> I have found that the following bad code gives "exception" at run
>> time instead of error message at compilation time (b18 Win95):
>>
>> #include <stdio.h>
>> main(){
>> printf("%s\n",sizeof(long));
>> }
>
>No compiler will detect this error at compile-time. The prototype for
>printf is (char *, ...); that is, no specific type information for
>anything except the first parameter. A compiler would have to read the
>first parameter to figure out the expected types for the remaining
>args, and much of the time that first parameter is dynamically computed
>at runtime instead of being a static string. There are a couple of
>lint-like programs that will catch this error with a
>compile-time-evaluatable format string, but that's the best you can do.
>
>Summary: learn more about the language before whining about compiler
>errors. This is a programmer bug, not a compiler bug.
Actually, this is a little harsh since GCC does, in fact, have a compile
time __attribute__ option for checking the arguments to a printf. If
the prototype for printf in /usr/include/stdio.h had included something like:
__attribute__((format(printf, 1, 2)));
it would have detected that programmer error.
--
http://www.bbc.com/ cgf@bbc.com "Strange how unreal
VMS=>UNIX Solutions Boston Business Computing the real can be."
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
next prev parent reply other threads:[~1997-10-06 18:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-10-06 1:19 Tage Westlund
1997-10-06 9:53 ` Jason Zions
1997-10-06 12:27 ` Steve Dum
1997-10-06 12:40 ` Matthew Moskewicz
1997-10-06 14:27 ` Marty Leisner
1997-10-06 17:13 ` Steve Tynor
1997-10-06 18:01 ` Chris Faylor [this message]
1997-10-06 15:47 ` Charles Curley
1997-10-07 6:18 ` Jon Thackray
1997-10-06 9:16 David C. Hoos, Sr.
1997-10-06 17:13 ` $Bill Luebkert
1997-10-07 0:12 Pascal OBRY
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=EHnp1A.6qs@bbc.com \
--to=cgf@bbc.com \
--cc=gnu-win32@cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).