[comp.lang.c] Functions that return pointers to unmodifiable data

rk9005@cca.ucsf.edu (Roland McGrath) (01/22/88)

Is there some reason why the ANSI C standard does not declare strerror:
	const char *strerror(int errnum);
?

It seems to me that it should be made clear that the user program
may not modify the data that the return value of strerror points to.
Also, if sys_errlist (or whatever) is defined:
	const char *sys_errlist[] = { "Error 0", /* ... */ };
Whether or not it is defined "const", in some implementations
(such as GCC), the string literals are put in read-only memory,
so attempting to write in the space pointed to by the return
of strerror may cause a trap.
-- 
		Roland McGrath
UUCP: 			...!ucbvax!lbl-rtsg.arpa!roland
ARPA:	 		roland@lbl-rtsg.arpa