delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/10/07/13:55:16

From: jont AT harlequin DOT co DOT uk (Jon Thackray)
Subject: A TINY BUG
7 Oct 1997 13:55:16 -0700 :
Message-ID: <199710070957.KAA09373.cygnus.gnu-win32@zaphod.long.harlequin.co.uk>
References: <3438330F DOT 61CF AT stockholm DOT mail DOT telia DOT com>
To: gnu-win32 AT cygnus DOT com

Tage Westlund writes:
 > To gnu designers!
 > 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));
 > }

C the language is not required to detect this error, and in the worst
case, simply can't. Consider

extern char *foo;
int main(int argc, char *argv[])
{
  printf(foo, sizeof(long));
  return 0;
}

The best a compiler could do would be to warn you that this might be
unsafe. OTOH, you may not want this behaviour, as you may believe that
programs should compile without errors or warnings, so that if errors
or warnigs are produced you know that you need to investigate them.
Many C compilers, at high warning levels, will detect the programmer
error you quote. But at the end of the day, with C, you are on your
own. C is not a safe language, and make no pretensions to be such. If
you wish to write in a safe language, perhaps you should try standard
ML.
-
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