Subject: Re: A TINY BUG
From: [email-masked] (Matthew Moskewicz)

6 Oct 1997 13:05:52 -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]

Jason Zions 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
[munch]
> 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

Jason, you are right in principal, and I hate to muddle 
the issue, but ... :)
gcc will indeed generate a warning for this. Perhaps the 
moral is that one should always turn on all compiler 
warnings.

[example]

sunlab1:~/cs217/scratch> cat test.c

#include<stdio.h>
int main ( void )
{
 
  printf("%s\n",sizeof(long));
  return 0;
}

sunlab1:~/cs217/scratch> gcc -Wall test.c
test.c: In function `main':
test.c:5: warning: format argument is not a pointer (arg 2)

--
 Matthew Moskewicz	|	mailto:[email-masked]
 24A Holder Hall - PU	|	http://www.Princeton.edu/~moskewcz	
 Princeton, NJ 08544    |
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".