Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!ogicse!ogicse.cse.ogi.edu!vegdahl From: vegdahl@ogicse.cse.ogi.edu (Steve Vegdahl) Newsgroups: comp.lang.c Subject: shared storage for string literals? Message-ID: <21996@ogicse.ogi.edu> Date: 28 May 91 19:51:29 GMT Sender: vegdahl@ogicse.ogi.edu Organization: Oregon Graduate Institute (formerly OGC), Beaverton, OR Lines: 20 The ANSI standard states that two identical string literals may share storage. Thus, whether the execution of the block: { char *a = "hello"; char *b = "hello"; printf("%s", a==b ? "YES" : "NO"); } prints "YES" is depends on the implementation. Question: can non-identical substrings share storage if one is a substring of the other, and they share a common "tail"? In other words, is it legal for an implementation to print "YES" when executing the following block: { char *a = "Say hello"; char *b = "hello"; printf("%s", (a+4)==b ? "YES" : "NO"); } I find nothing in the standard that gives a definitive answer to this question. Steve Vegdahl Adaptive Solutions, Inc.