Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 98568 invoked from network); 6 Feb 2004 12:34:28 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 6 Feb 2004 12:34:28 -0000 Received: (qmail 21931 invoked by uid 500); 6 Feb 2004 12:34:25 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 21894 invoked by uid 500); 6 Feb 2004 12:34:24 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 21868 invoked from network); 6 Feb 2004 12:34:23 -0000 Message-ID: <402389CE.50901@algroup.co.uk> Date: Fri, 06 Feb 2004 12:34:22 +0000 From: Ben Laurie User-Agent: Mozilla Thunderbird 0.5b (Windows/20040204) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Joe Orton Cc: dev@apr.apache.org Subject: Re: [PATCH] optional hook macros References: <20040205171129.GA29555@manyfish.co.uk> <40236716.20705@algroup.co.uk> <20040206103107.GA13618@redhat.com> In-Reply-To: <20040206103107.GA13618@redhat.com> X-Enigmail-Version: 0.83.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Joe Orton wrote: > On Fri, Feb 06, 2004 at 10:06:14AM +0000, Ben Laurie wrote: >>Surely the point is that the function and the function pointer actually >>_do_ have compatible types, but we hold the pointer in a variable that >>doesn't. That is, we cast it to an incompatible type for storage, then >>cast it back. > > The issue is the call to apr_dynamic_fn_register, here's how I read it: > > (((void (*)(const char *, APR_OPTIONAL_FN_TYPE(name) *)) > &apr_dynamic_fn_register)(#name,name)) > > this takes a function pointer (&apr_dynamic_fn_register), then casts it > to a different type (void (*)(const blah blah)), then calls the function > using this type. That has undefined behaviour, since the type of > apr_dynamic_fn_register is not compatible with the (void (*)(const blah > blah) type. I misunderstood, sorry. Cheers, Ben. -- http://www.apache-ssl.org/ben.html http://www.thebunker.net/ "There is no limit to what a man can do or how far he can go if he doesn't mind who gets the credit." - Robert Woodruff