🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2092

Re: on "use", and the lvalue-ness of string literals

#2092
From: Blair P. Houghton
Date: Sun, 08 Nov 1992 22:30
54 lines
2570 bytes
In article <18277@ksr.com> jfw@ksr.com (John F. Woods) writes:
>If you cannot deduce that "foo" has array type from "The multibyte character
>sequence is used to initialize an array of static storage duration and length
>just sufficient to contain the sequence", then I suggest you quietly put your
>keyboard down and go and lie down until the urge to program passes.

What I deduce from that is that the "multibyte character
sequence" is not itself an array but an indicator of the
initial values of an actual array.  The sentence says
nothing about the type of the source of the characters,
it gives rather that of the destination.

And the nap was nice, thanks.

>The only time a string literal does not become an anonymous array is when it

"Does not become?"  Not "is not?"  You contradict yourself.

Your eyelids are growing heavy.

>is used as an initializer (read "Initialization 3.5.7").  In all other cases
>it is an array and has array type.  Therefore, when it appears in an lvalue
>context, it is not a modifiable lvalue (because lvalues of array type are
>not modifiable (see 3.2.2.1 Lvalues and Function Designators)),

It is not a modifiable lvalue because the standard explicitly
forbids attempts to modify it.

You are getting sleepy, very sleeeeeepy.

>and therefore
>"foo" = "bar"; violates the Constraint in section 3.3.16 that "An assignment
>operator shall have a modifiable lvalue as its left operand", an therefore
>a compiler *must* issue a diagnostic.  The statement about modifying string
>literals doesn't enter into it.

The cookies of the bull are many and near.  This is only
one of a number greater than one of reasons that this
assignment is bogus.  I would not attempt to tell a compiler
writer which reason to deduce first; it could upset his
syntax tree.

You are aSLEEP!

>>E.g.,
>>	"foo"[2] = 'g';
>>results in undefined behavior.
>
>But no diagnostic is required in this case, because no Constraint is violated.

When I snap my fingers, you will awake.

				--Blair
				  "Is that a TAMBOURINE I see behind you?"
Technical Details
Message-ID: <1dk4d8INNe29@chnews.intel.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!littlei!hfglobe!chnews!sedona!bhoughto
References: <27143@dog.ee.lbl.gov> <1992Nov2.200406.18152@ichips.intel.com> <18277@ksr.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!littlei!hfglobe!chnews!sedona!bhoughto
From: bhoughto@sedona.intel.com (Blair P. Houghton)
Newsgroups: comp.std.c
Subject: Re: on "use", and the lvalue-ness of string literals
Message-ID: <1dk4d8INNe29@chnews.intel.com>
Date: 8 Nov 92 22:30:00 GMT
References: <27143@dog.ee.lbl.gov> <1992Nov2.200406.18152@ichips.intel.com> <18277@ksr.com>
Organization: Intel Corp., Chandler, Arizona
Lines: 54
NNTP-Posting-Host: alfalfa.intel.com