Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail |
|---|---|
| From | Kazutoshi Satoda <k_satoda@f2.dion.ne.jp> |
| Newsgroups | comp.std.c++ |
| Subject | Re: Defect Report: Wordings on basic_string::data() disallow small-string optimization |
| Date | Sun, 28 Aug 2011 08:42:30 -0700 (PDT) |
| Organization | unknown |
| Lines | 40 |
| Sender | std-cpp-request@vandevoorde.com |
| Approved | james.dennett@gmail.com |
| Message-ID | <4E591721.2020208@f2.dion.ne.jp> (permalink) |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| X-Trace | news.albasani.net qlL/DWI6dFXpRbkohh4W+jwBGmA/2Gv/tGGpp4Ajy7WJaQ2KV70tem55tgQbMofjAJtB059x4klZtuD9BIde8w== |
| NNTP-Posting-Date | Sun, 28 Aug 2011 15:42:31 +0000 (UTC) |
| Injection-Info | news.albasani.net; logging-data="ElhHsrEr/JWQ06pJfdT+afdv15/40IH6g8BWIlTrhE2TeSw2R26ij73xTaHTDrwMV1UfHE23ew683w9IVKom6r2Ryb/u8UWIiE6chENrnYhqk3WohXV+X96qQJWvmBkH"; mail-complaints-to="abuse@albasani.net" |
| X-Mailer | Perl5 Mail::Internet v2.05 |
| X-Submission-Address | std-cpp-submit@vandevoorde.com |
| Cancel-Lock | sha1:lMzlAf1uZngnVfVjCdBVlx8k/4k= |
| X-Original-Date | Sun, 28 Aug 2011 01:11:13 +0900 |
| Xref | x330-a1.tempe.blueboxinc.net comp.std.c++:262 |
Show key headers only | View raw
> You cannot make normative conclusions from this code, because it invokes > undefined behaviour. This is so, because the expression > > x = std::move(str) > > calls a function that (potentially) invalidates the pointer returned > fromstr.data(), based on 21.4.1 [string.require] p6: > > "References, pointers, and iterators referring to the elements of a > basic_string sequence may be invalidated by the following uses of that > basic_string object: > � as an argument to any standard library function taking a reference to > non-const basic_string as an argument.(footnote) > � Calling non-const member functions, except operator[], at, front, > back, begin, rbegin, end, and rend." In the previous reply, I took "standard library function taking a reference to ..." as std::move() in the above expression. But if you are referring operator=(basic_string&&) itself as the trigger of invalidation, it seems impossible to show the problem with a valid C++ code example, because comparison of pointers is the only way in C++ to examine the effect on data(). > > data(): points at the array whose first element was pointed at by str.data() Returning to the original DR; It is not possible to confirm the above effect of data() if small-string optimization is implemented, because data() may point an small array which is distinct for each basic_string instance to decrease the number of allocation. -- k_satoda [ comp.std.c++ is moderated. To submit articles, try posting with your ] [ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Back to comp.std.c++ | Previous | Next — Next in thread | Find similar
Re: Defect Report: Wordings on basic_string::data() disallow small-string optimization Kazutoshi Satoda <k_satoda@f2.dion.ne.jp> - 2011-08-28 08:42 -0700 Re: Defect Report: Wordings on basic_string::data() disallow small-string optimization Daniel Krügler<daniel.kruegler@googlemail.com> - 2011-08-28 11:07 -0700
csiph-web