From:	CSBVAX::CSBVAX::MRGATE::"SMTP::PREP.AI.MIT.EDU::INFO-GCC-REQUEST"  5-DEC-1988 23:24
To:	MRGATE::"ARISIA::EVERHART"
Subj:	GCC/stdio interaction (ultrix, maybe others)


Received: from TUT.CIS.OHIO-STATE.EDU by prep.ai.mit.edu; Fri, 2 Dec 88 18:36:22 EST
Received: by tut.cis.ohio-state.edu (5.59/2.881128)
	id AA21875; Fri, 2 Dec 88 18:29:18 EST
Received: from USENET by tut.cis.ohio-state.edu with netnews
	for info-gcc@prep.ai.mit.edu (info-gcc@prep.ai.mit.edu)
	(contact usenet@tut.cis.ohio-state.edu if you have questions)
Date: 2 Dec 88 14:06:45 GMT
From: mcvax!jack@uunet.uu.net  (Jack Jansen)
Subject: GCC/stdio interaction (ultrix, maybe others)
Message-Id: <7747@boring.cwi.nl>
Sender: info-gcc-request@prep.ai.mit.edu
To: info-gcc@prep.ai.mit.edu


The following is probably not a bug in GCC, but in Ultrix (and maybe
other) stdio. However, gcc triggers the bug because it stores
strings in read-only space.

What happens is that the following program will dump core:
--------
main() {
    int i;
    short j;

    i = sscanf("1", "%hd", &j);
    printf("i=%d, j=%d\n", i, j);
}
---------
What happens is the following: sscanf sets up a dummy FILE * structure,
points the buffer/pointer to the argument string "1" and calls _doscan.

Doscan, however, will call ungetc() at some point. Ungetc will try to
stuff a character back into the input buffer. BANG!

Just thought I'd warn the rest of the net....
--
Fight war, not wars			| Jack Jansen, jack@cwi.nl
Destroy power, not people! -- Crass	| (or mcvax!jack)
