Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #89292
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Order of addresses of string-literals inside a translation unit |
| Date | 2023-02-24 09:03 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <86y1on9ers.fsf@linuxsc.com> (permalink) |
| References | <tt55du$1h8fk$1@dont-email.me> <6pzJL.248610$PXw7.31730@fx45.iad> <tt6rto$1pkqc$3@dont-email.me> <87lekooxri.fsf@nosuchdomain.example.com> |
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes: [string literals may overlap] > The standard *could* have required that two occurrences of "hello" in > the same program must refer to distinct objects with unequal addresses > (and code could have taken advantage of that guarantee). But in fact it > explicitly says that it's unspecified. > > C++17 5.13.5p16 [lex.string]: > > Evaluating a string-literal results in a string literal object > with static storage duration, initialized from the given > characters as specified above. Whether all string literals are > distinct (that is, are stored in nonoverlapping objects) and > whether successive evaluations of a string-literal yield the > same or a different object is unspecified. [ Note: The effect > of attempting to modify a string literal is undefined. ? end > note ] > > I hadn't realized until now that the standard allows two evaluations of > the same string literal to refer to distinct objects (and it's difficult > to imagine an implementation choice that would make them distinct). IIANM the statement about two evaluations is present in C++ but not in C.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Order of addresses of string-literals inside a translation unit Bonita Montero <Bonita.Montero@gmail.com> - 2023-02-22 14:31 +0100
Re: Order of addresses of string-literals inside a translation unit Richard Damon <Richard@Damon-Family.org> - 2023-02-22 20:34 -0500
Re: Order of addresses of string-literals inside a translation unit James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-02-23 00:00 -0500
Re: Order of addresses of string-literals inside a translation unit Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-02-23 13:52 -0800
Re: Order of addresses of string-literals inside a translation unit Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-02-24 09:03 -0800
Re: Order of addresses of string-literals inside a translation unit Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-02-24 08:55 -0800
Re: Order of addresses of string-literals inside a translation unit "james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu> - 2023-02-24 09:43 -0800
Re: Order of addresses of string-literals inside a translation unit Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-03-14 08:48 -0700
Re: Order of addresses of string-literals inside a translation unit Öö Tiib <ootiib@hot.ee> - 2023-02-22 23:59 -0800
Re: Order of addresses of string-literals inside a translation unit scott@slp53.sl.home (Scott Lurndal) - 2023-02-23 16:18 +0000
csiph-web