embedded questions!!!

I'd like to see it in the standard, but I looked at your reference in K&R 2nd ed. And it says what you say it says.

That's what K&R 2nd ed. appears to say. I'm with you, there.

I wasn't thinking of OO here. However, I'll see if I can find the point referenced in C99 or C89. I like the points you've made, but I'm still curious.

Jon

Reply to
Jonathan Kirwan
Loading thread data ...

In the standard, these excerpts and examples might be relevant:

6.5.2.5 Compound literals

9 String literals, and compound literals with const-qualified types, need not designate distinct objects.82)

82) This allows implementations to share storage for string literals and constant compound literals with the same or overlapping representations.

...

6.5.2.5 Compound literals

13 EXAMPLE 5 The following three expressions have different meanings: "/tmp/fileXXXXXX" (char []){"/tmp/fileXXXXXX"} (constat char []){"/tmp/fileXXXXXX"}

The first always has static storage duration and has type array of char, but need not be modifiable; the last two have automatic storage duration when they occur within the body of a function, and the first of these two is modifiable.

14 EXAMPLE 6 Like string literals, const-qualified compound literals can be placed into read-only memory and can even be shared.

For example,

(constat char []){"abc"} == "abc"

might yield 1 if the literals? storage is shared.

6.7.3 Type Qualifiers

If an attempt is made to modify an object defined with a const-qualified type through use of an value with non-const-qualified type, the behavior is undefined.

Best regards, Spehro Pefhany

--
"it's the network..."                          "The Journey is the reward"
speff@interlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
Reply to
Spehro Pefhany

Thanks much. You just saved me some time, this evening!

Jon

Reply to
Jonathan Kirwan

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.