This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Missed optimization with const member


On 05/07/2017 17:24, Martin Sebor wrote:

[*] While the example (copied below) is valid, accessing the object
after someFunction() has returned via a reference or pointer to it
is not.

   void somefunction(const Object& object);
   {
     void* p = &object;
     object.~Object();
     new(p) Object();
   }

I think it's problematic as explained in p0532r0.pdf. We construct and destroy objects in the internal buffer of std::vector and we don't update the pointer every time. I don't see myself understanding when std::launder must be used, looks too expert-grade feature.

Best,

Ion


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]