Subject: Re: A TINY BUG
From: [email-masked] (Jason Zions)

6 Oct 1997 10:09:33 -0700
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: [email-masked]
Cc: [email-masked]

> 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.

Jason Zions
Softway Systems Inc., makers of OpenNT
http://www.opennt.com

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".