From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4727 invoked by alias); 29 Apr 2008 23:52:57 -0000 Received: (qmail 4707 invoked by uid 22791); 29 Apr 2008 23:52:56 -0000 X-Spam-Check-By: sourceware.org Received: from an-out-0708.google.com (HELO an-out-0708.google.com) (209.85.132.249) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 29 Apr 2008 23:52:36 +0000 Received: by an-out-0708.google.com with SMTP id c28so51481ana.104 for ; Tue, 29 Apr 2008 16:52:32 -0700 (PDT) Received: by 10.100.140.15 with SMTP id n15mr76109and.87.1209513152120; Tue, 29 Apr 2008 16:52:32 -0700 (PDT) Received: from ?172.17.172.101? ( [68.57.61.87]) by mx.google.com with ESMTPS id 10sm879557wrl.11.2008.04.29.16.52.30 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 29 Apr 2008 16:52:31 -0700 (PDT) Message-ID: <4817BD31.5000402@gmail.com> Date: Wed, 30 Apr 2008 01:17:00 -0000 From: Robert William Fuller User-Agent: Thunderbird 2.0.0.6 (X11/20071019) MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: OT Rant on why C++ Sucks (Was Re: strict aliasing: how to swap pointers) References: <481785A7.3060506@mit.edu> <00b701c8aa51$ef2c9b50$cd85d1f0$@net> In-Reply-To: <00b701c8aa51$ef2c9b50$cd85d1f0$@net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-04/txt/msg00391.txt.bz2 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 T* exchange(T** ptr, T* next); > > exchange(&a, &v2); > > since you're using C++ here. 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.