Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #261

Re: Defect Report: Wordings on basic_string::data() disallow small-string optimization

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder1.news.weretis.net!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:08 -0700 (PDT)
Organization unknown
Lines 55
Sender std-cpp-request@vandevoorde.com
Approved james.dennett@gmail.com
Message-ID <4E58FF73.7070503@f2.dion.ne.jp> (permalink)
Content-Type text/plain; charset=UTF-8; format=flowed
X-Trace news.albasani.net Up8/Csp3YcrNIhf18pEXpxtcL5f6YpdVm7ENgrYTYWf3P25FdSV37Rxki5escPh9V5HYQGMHoOfKI06vXZEhQQ==
NNTP-Posting-Date Sun, 28 Aug 2011 15:42:09 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="RMod77lfl9HY5SkCuUN96ur03nEvpof6Y4bdP9OULaBb3Mkx8pvBzaH4w13cnikTdDdyuMO4e6N0Una238xcJhuUO9Sol8Li/LLCzwM35bLcWDUmMCC+CZyiralVRy3U"; mail-complaints-to="abuse@albasani.net"
X-Mailer Perl5 Mail::Internet v2.05
X-Submission-Address std-cpp-submit@vandevoorde.com
Cancel-Lock sha1:qFlL/KWDTxP+7uW23dQ+Y7gVuu4=
X-Original-Date Sat, 27 Aug 2011 23:30:11 +0900
Xref x330-a1.tempe.blueboxinc.net comp.std.c++:261

Show key headers only | View raw


The original subject was:
Defect Report: Wordings on basic_string::data() disallow small-string
optimization

The last "optimization" was wrapped and dropped from subject for some
reason (80 columns?).


Daniel Kr�gler wrote:
>
> On 2011-08-24 03:56, Kazutoshi Satoda wrote:
>>
>>     void f(std::string&    x, std::string&&    str)
>>     {
>>       char const* const was_pointed = str.data();
>>       x = std::move(str);
>>       assert(x.data() == was_pointed);
>>     }

(snip)
>
> 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(), ...

Then, replace the example with this one:

 void f(std::string& x, std::string&& str)
 {
   char const* const was_pointed = str.data();
   x = static_cast<std::string&&>(str);
   assert(x.data() == was_pointed);
 }

>>  I think these wordings of effects on data() are unintentionally
>>  over-constraining, and should be relaxed to keep the rationale for
>>  C.2.11 "Allow small-string optimization" really valid.
>
> I have not yet seen an example which proves this. Your above given
> example is invalid.

I believe the above revised example is now good to show the problem.

--
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 | NextNext in thread | Find similar


Thread

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:06 -0700

csiph-web