Return-Path: Delivered-To: new-httpd-archive@hyperreal.org Received: (qmail 3021 invoked by uid 6000); 11 Apr 1998 15:57:13 -0000 Received: (qmail 3011 invoked from network); 11 Apr 1998 15:57:10 -0000 Received: from eastwood.aldigital.algroup.co.uk (194.128.162.193) by taz.hyperreal.org with SMTP; 11 Apr 1998 15:57:10 -0000 Received: from freeby.ben.algroup.co.uk (freeby.ben.algroup.co.uk [193.133.15.6]) by eastwood.aldigital.algroup.co.uk (8.6.12/8.6.12) with ESMTP id PAA10514 for ; Sat, 11 Apr 1998 15:56:21 GMT Received: from algroup.co.uk (naughty.ben.algroup.co.uk [193.133.15.107]) by freeby.ben.algroup.co.uk (8.6.12/8.6.12) with ESMTP id QAA14850 for ; Sat, 11 Apr 1998 16:56:09 +0100 Message-ID: <352F9281.4822E430@algroup.co.uk> Date: Sat, 11 Apr 1998 16:55:45 +0100 From: Ben Laurie Organization: A.L. Digital Ltd. X-Mailer: Mozilla 4.04 [en] (WinNT; I) MIME-Version: 1.0 To: new-httpd@apache.org Subject: Re: [PATCH] Resolve BUILD warnings under ULTRIX/mips (take 3) References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: new-httpd-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org Dean Gaudet wrote: > > Nah casts aren't ever safe ;) > > Need I drag out the crypto example again? Such an innocent cast... such a > devastating effect. The code looked something like this: > > tmp = (unsigned)gen_salt; > > when it was supposed to be: > > tmp = (unsigned)gen_salt(); > > A world of difference between the two of course. But the cast hides it. > I forget what code it was in, but that's a real life mistake. > > And C++ doesn't help it. That's where you are wrong: tmp=static_cast(gen_salt); catches this mistake: Test7.cpp(155) : error C2440: 'static_cast' : cannot convert from 'int (__cdecl *)(void)' to 'unsigned int' This conversion requires a reinterpret_cast, a C-style cast or function-style cast It does irritate me that people are so prejudiced against something they don't even know how to use. (BTW, I tested this on VC++ and g++. g++ didn't work (version 2.7.x)). Cheers, Ben. -- Ben Laurie |Phone: +44 (181) 735 0686| Apache Group member Freelance Consultant |Fax: +44 (181) 735 0689|http://www.apache.org and Technical Director|Email: ben@algroup.co.uk | A.L. Digital Ltd, |Apache-SSL author http://www.apache-ssl.org/ London, England. |"Apache: TDG" http://www.ora.com/catalog/apache