string assignment in C

Karl Heuer karl at haddock.ima.isc.com
Thu Oct 20 13:30:58 AEST 1988


In article <8696 at smoke.ARPA> gwyn at brl.arpa (Doug Gwyn) writes:
>... As it stands, if p1 and p2 are pointers to const char, the storage may be
>shared, but not if they are pointers to char....  Thus the automatic "dumb"
>crunching together of string literals is not permitted in a standard-
>conforming implementation.

True in K&R C, but fixed in dpANS: "Identical string literals ... need not be
distinct.  If the program attempts to modify a string literal ... the behavior
is undefined." [3.1.4]  "This specification allows implementations to share
copies of [identical] strings." [R3.1.4]

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list