delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/10/06/13:05:52

From: moskewcz AT Princeton DOT EDU (Matthew Moskewicz)
Subject: Re: A TINY BUG
6 Oct 1997 13:05:52 -0700 :
Message-ID: <34393E69.7CC5.cygnus.gnu-win32@Princeton.edu>
References: <3438330F DOT 61CF AT stockholm DOT mail DOT telia DOT com>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

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:moskewcz AT Princeton DOT edu
 24A Holder Hall - PU	|	http://www.Princeton.edu/~moskewcz	
 Princeton, NJ 08544    |
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019