Problem in sscanf with gcc-1.37 ?

David W. Berry dwb at archer.apple.com
Sat Jul 28 02:24:05 AEST 1990


In article <2204 at s3.ireq.hydro.qc.ca> lamarche at ireq.hydro.qc.ca () writes:
	What you're seeing is a side effect of the fact that gcc
puts strings into text space.  To defeat this you can specify the
-fwritable-strings flag to gcc.

>main  ()
>{
>   char works[] = "Works 1 2";
	This allocates 10 bytes on the stack and then copies a string
from text space to the stack space.  Under most C compilers, it isn't
even allowed...

>   char* fails = "Fails 1 2";
	This allocates 4 bytes on the stack and puts a pointer to the
string in text space in the stack space.

Since the data that fails points to is not writable, when _doscan trys
to do an ungetc, it fails with a buserror.

	David
	David W. Berry			A/UX Toolbox Engineer
	dwb at apple.com



More information about the Comp.unix.aux mailing list