Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!think!husc6!cmcl2!brl-adm!adm!gea@Juliet.Caltech.EDU From: gea@Juliet.Caltech.EDU Newsgroups: comp.lang.c Subject: Local string storage -- *guaranteed* static? Message-ID: <7690@brl-adm.ARPA> Date: Wed, 3-Jun-87 18:16:37 EDT Article-I.D.: brl-adm.7690 Posted: Wed Jun 3 18:16:37 1987 Date-Received: Sat, 6-Jun-87 04:19:52 EDT Sender: news@brl-adm.ARPA Lines: 26 Someone asked whether strings in functions like func() { char *str = "some string"; ... return(str); } are static, and several people affirmed that they were, but without any evidence. Certainly on all architectures that I am familiar with, even on most that I can imagine, it will be far easier on the compiler if these are static data. But is there any guarantee, either in K&R or in the Draft Standard, that this data will be static? By the way, the question can be avioded if the function is re-written as: func() { static char str[] = "some string"; ... return(str); } Moral: Don't make assumptions when you can tell the compiler what you mean. Gary Ansok gea@romeo.caltech.edu or ansok@scivax.arpa