Path: utzoo!telly!ddsw1!lll-winken!uunet!mcvax!jack
From: jack@cwi.nl (Jack Jansen)
Newsgroups: gnu.gcc
Subject: GCC/stdio interaction (ultrix, maybe others)
Message-ID: <7747@boring.cwi.nl>
Date: 2 Dec 88 14:06:45 GMT
Sender: news@cwi.nl
Lines: 24


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)