[cfe-dev] Proposed C++ optimization with big speed gains with big objects

Ladislav Nevery neuralll at gmail.com
Tue Sep 25 05:57:56 PDT 2012


>The user did no such thing. The user decided to create a temporary and 
>then move-assign it to the old position. 

No the user said let there be 1000 static objects 
and let first one be initialized with those parameters.
The fact the nothing in code says how this goal is reached is good thing
since it allows us to do it in efficient way.


>You want the compiler to decide 
>for him that instead there will be a placement new without calling the 
>destructor.

No I want this destructor be called and behave exactly like placement new
part of standard. ie deleting only members. 

>Which, by the way, is in no way defined by the C++ standard. 

One optimization switch speeding all your old code without any change will
be well worth it for many since it will produce faster and smaller code than
zillion heap only && operators copy pasted everywhere.

>You're 
>overwriting an object without properly ending its life. You're misusing 
>an object as raw memory. 
>You're invoking undefined behavior. End of story.

No behavior and memory usage of basic object / members / destructors etc.
is exactly as defined in standard for placement new. So whole behavior is
exactly the same since copy of placement new code is used to implement it.

>If you want to do that in your code, that's your business, and C++ won't 
>stop you from explicitly using placement new. Don't ask the compiler to 
>do it for you, because that is just insanely dangerous.

I don's see the danger there any more than with placement new which is
already part of clang and standard.

>And as a side effect, you get subtle bugs. Yay!

Can you make some example?

_______________________________________________
cfe-dev mailing list
cfe-dev at .uiuc
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





--
View this message in context: http://clang-developers.42468.n3.nabble.com/Proposed-C-optimization-with-big-speed-gains-with-big-objects-tp4026886p4026918.html
Sent from the Clang Developers mailing list archive at Nabble.com.



More information about the cfe-dev mailing list