Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!eplrx7!lad From: lad@eplrx7.UUCP (Lawrence Dziegielewski) Newsgroups: comp.lang.c Subject: bug (?) in 4.(2,3)? Message-ID: <462@eplrx7.UUCP> Date: Thu, 27-Aug-87 16:04:29 EDT Article-I.D.: eplrx7.462 Posted: Thu Aug 27 16:04:29 1987 Date-Received: Sat, 29-Aug-87 11:52:01 EDT Organization: E.I. DuPont Co. Engineering Physics Lab Lines: 43 Keywords: external declaration of a system call Consider the following program: ------------------------------------ #include char fstat; main() { FILE *fp; fp = fopen("testfile", "w"); fprintf(fp, "xxxxx"); fclose(fp); } ------------------------------------ On our Sun Unix 3.4 and DEC Ultrix 2.0, it results in either a "bus error" or "segmentation fault", which occurs deep within the fprintf(). On Unix System V and MS-DOS Lattice C, it executes without problem, as it should. The problem is that the character variable 'fstat', declared externally, conflicts with the fstat() system call. If this is indeed a problem for Berkley, then the compiler ought flag the external declaration as a redeclaration, but this is not the case, it compiles without incident. Also note that fstat is declared char, fstat() is int. This feature is not limited to fstat() - it fails just as well for other system calls. (But not on System V or Lattice C). -- Lawrence A. Dziegielewski | E.I. Dupont Co. {uunet!dgis!psuvax1}!eplrx7!lad | Engineering Physics Lab Cash-We-Serve 76127,104 | Wilmington, Delaware 19891 MABELL: (302) 695-1311 | Mail Stop: E357-318