A TINY BUG

Matthew Moskewicz moskewcz@Princeton.EDU
Mon Oct 6 12:40:00 GMT 1997


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@Princeton.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@cygnus.com" with one line of text: "help".


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /