Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ucbvax!ucsfcgl!cca.ucsf.edu!rk9005 From: rk9005@cca.ucsf.edu (Roland McGrath) Newsgroups: comp.lang.c Subject: Functions that return pointers to unmodifiable data Message-ID: <1140@ucsfcca.ucsf.edu> Date: 22 Jan 88 06:47:46 GMT Reply-To: roland@rtsg.lbl.gov (Roland McGrath) Organization: Hackers Anonymous International, Ltd., Inc. (Applications welcome) Lines: 16 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