OT Rant on why C++ Sucks (Was Re: strict aliasing: how to swap pointers)

Gareth Buxton gareth.buxton@googlemail.com
Wed Apr 30 03:03:00 GMT 2008


On Tue, 29 Apr 2008 20:28:33 -0400
Robert William Fuller <hydrologiccycle@gmail.com> wrote:

> Rupert Wood wrote:
> > Evan Jones wrote:
> > 
> >> I have a function to swap any two pointers (assuming that
> >> sizeof(void*) == sizeof(T*)). I would like to use it without
> >> violating strict aliasing rules.
> > 
> > I don't know how to fight aliasing rules but as another approach
> > you could template the function instead, i.e.
> > 
> >      template<typename T> T* exchange(T** ptr, T* next);
> > 
> >      exchange<int>(&a, &v2);
> > 
> > since you're using C++ here.
> 
> </begin rant>
> 
> What a fabulous idea for a programming language!  Why not instantiate 
> code for every subtle variation of a type?  Then, create a giant
> library called STL for that very purpose.  Watch your executables
> grow to multiple megabytes in size guaranteeing they won't fit into
> the cache of any processor.  What better way to bring your quad-core
> processor to its knees.  All hail the grand design of C++!
> 
> Ah, thank you :-)  I feel better now.  That was cathartic.
> 
> </end rant>

Clearly we just need bigger processor caches. Those boys down in
hardware just been slacking. Not keeping up with the latest
developments in software!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20080430/a64d657d/attachment-0001.sig>


More information about the Gcc-help mailing list