delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/10/06/14:39:39

From: leisner AT sdsp DOT mc DOT xerox DOT com (Marty Leisner)
Subject: Re: A TINY BUG
6 Oct 1997 14:39:39 -0700 :
Message-ID: <9710062126.AA21944.cygnus.gnu-win32@gnu.sdsp.mc.xerox.com>
References: <34391696 DOT 27758E19 AT softway DOT com>
Mime-Version: 1.0
To: Jason Zions <jazz AT softway DOT com>
Cc: tage DOT westlund AT stockholm DOT mail DOT telia DOT com, gnu-win32 AT cygnus DOT com


I agree, but -Wformat should even catch this (without stdio.h)

Or use -Wall...

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


-- 
marty
leisner AT sdsp DOT mc DOT xerox DOT com  
The Feynman problem solving Algorithm
        1) Write down the problem
        2) Think real hard
        3) Write down the answer
                Murray Gel-mann in the NY Times




-
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