*BSD News Article 9188


Return to BSD News archive

Received: by minnie.vk1xwt.ampr.org with NNTP
	id AA5324 ; Wed, 23 Dec 92 10:01:16 EST
Xref: sserve comp.lang.c:37095 comp.unix.bsd:9245
Newsgroups: comp.lang.c,comp.unix.bsd
Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!darwin.sura.net!bogus.sura.net!pandora.pix.com!stripes
From: stripes@pix.com (Josh Osborne)
Subject: Re: Segmentation faults
Message-ID: <BzMFF4.Aut@pix.com>
Sender: news@pix.com (The News Subsystem)
Nntp-Posting-Host: pandora.pix.com
Organization: Pix Technologies -- The company with no adult supervision
References: <1gricmINNsl@ub.d.umn.edu> <1992Dec18.134225.20548@Logix.DE> <veit.724925472@du9ds3>
Date: Mon, 21 Dec 1992 18:01:51 GMT
Lines: 22

In article <veit.724925472@du9ds3> veit@du9ds3.fb9dv.uni-duisburg.de writes:
[...]
>This is a real problem where sizeof(int) != sizeof(char*), for instance with
>Turbo C or Microsoft C or similar 16bit junk. But if you compile this
>with a 32bit K&R compiler, and sizeof(int)==sizeof(char*) (=4), it won't see 
>a difference, because it will just take 32bit from the parameter stack 
>and push it as a 32bit argument to printf.

(which masks many bugs, which will show up on, say the Alpha)

>The compiler cannot find out the real expected type (it cannot do parsing
>of the format string in general!).

Not in general, but gcc CAN verify printf/scanf style args and parms as
long as the format string is a constant.  See __attribute__ in the gcc
manual.
-- 
           stripes@pix.com              "Security for Unix is like
      Josh_Osborne@Real_World,The          Multitasking for MS-DOS"
      "The dyslexic porgramer"                  - Kevin Lockwood
We all agree on the necessity of compromise.  We just can't agree on
when it's necessary to compromise.       - Larry Wall