patch to make libkdtree compatible with g++-4.2 and g++-4.3

Sylvain Bougerel sylvain.bougerel.devel at gmail.com
Fri Oct 31 01:58:41 UTC 2008


On Sun, Oct 26, 2008 at 12:29 PM, Paul Harris <paulharris at computer.org> wrote:
> (resent) sorry had to compress the patch, the original email is stuck in the
> moderator's queue...
>
>
> Hi all,
>
> I'll continue this email thread... attached is a smallish patch (I'm not
> familiar with git so I started smallish).  It removes all the method
> specifiers that say throw()... eg
>
> void do_something throw() { }
>
> The throw() things are not desirable as kdtree should be exception
> transparent... the throw()s caused problems with my program, as sometimes
> accessors could throw an exception - and the no-throw guarantee that kdtree
> was imposing prevented it from compiling.
>
> I also had trouble compiling kdtree for a visual c++ 2005 program, because
> (IIRC) of the use of GCC's __throw_exception_again extension.
>
> Instead, I switched to a class-destructor pattern (I forget the patterns
> name) which basically uses a class to manage the lifetime of the pointer...
>
> _Link_type _M_new_node( etc)
> {
>         typename _Base::NoLeakAlloc noleak(this);  <-- see allocator.hpp for
> definition. this allocs memory
>          _Link_type new_node = noleak.get();   <-- just get the pointer from
> noleak
>          _M_construct_node(new_node, __V, __PARENT, __LEFT, __RIGHT);  <--
> do the thing that could throw an exception
>          noleak.disconnect();  <--- if we are here, then all went well. call
> this function that stops noleak from deallocating on destruction
>          return new_node;
> }
>
> else if construct_node threw an exception, noleak's destructor would
> automatically dealloc the node.
>
>
>
> I also extended the 'examples' Makefile so it'll try compiling it with gcc
> 3.4, 4.2 and 4.3 (run make all_gcc). I corrected a minor problem in the test
> file (missing include file).
>
>
> Note that I have a bunch more changes to work through, but I need to merge
> the changes from the trunk into mine first... so I thought I'd start with
> this throw() task.  BUT that means I haven't tested out kdtree on my
> application, so if people could please test out this patch, reject or accept
> it, that would be great.
>
> cheers
> Paul
>
>
> 2008/10/26 Paul Harris <paulharris at computer.org>
>>
>> I agree, it is time to revise naming.  I did some revision on my local
>> version but with less underscores.
>>
>> I suggest we make small changes (such as this patch) to libkdtree for
>> debian's release packaging for the moment since Lenny needs to stablise very
>> soon, and I'll see if we can get the ball rolling on merging in bigger
>> changes for 0.7.0
>>
>> I'll have a quick look now to see if there are any other small changes
>> from my local version that I can bring in to 0.6.3...
>>
>> 2008/10/25 martin f krafft <madduck at debian.org>
>>>
>>> also sprach Martin SCHREIBER <martin.schreiber at in.tum.de>
>>> [2008.10.25.0404 +0200]:
>>> > is it possible that you patch the git sources and create a new
>>> > version 0.6.3?
>>>
>>> Even though the patch might well work, it strikes me as hackish.
>>> Maybe it's time to revise the naming completely?
>>>
>>> Cheers,
>>>
>>> --
>>>  .''`.   martin f. krafft <madduck at debian.org>
>>> : :'  :  proud Debian developer, author, administrator, and user
>>> `. `'`   http://people.debian.org/~madduck - http://debiansystem.info
>>>  `-  Debian - when you have better things to do than fixing systems
>>>
>>> in africa some of the native tribes have a custom of beating the
>>> ground with clubs and uttering spine chilling cries. anthropologists
>>> call this a form of primitive self-expression. in america they call
>>> it golf.
>>>
>>> -----BEGIN PGP SIGNATURE-----
>>> Version: GnuPG v1.4.9 (GNU/Linux)
>>>
>>> iEYEARECAAYFAkkC9boACgkQIgvIgzMMSnVUTgCghHcFfomXpiBsUyCOLFKFvNVc
>>> /BEAn1PVy1F2qgXqYQanTpn+VCPBBSt2
>>> =DBLS
>>> -----END PGP SIGNATURE-----
>>>
>>> _______________________________________________
>>> libkdtree-devel mailing list
>>> libkdtree-devel at lists.alioth.debian.org
>>> http://lists.alioth.debian.org/mailman/listinfo/libkdtree-devel
>>>
>>
>
>
>
> _______________________________________________
> libkdtree-devel mailing list
> libkdtree-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/libkdtree-devel
>
>

Hi,

Sorry for the delay, I came back from holiday 2 days ago. Problem is:
I'm going oversees tonight too. If I have time, before I take the
flight, I'll push the patch into the tree and create a new version.

I completely agree with the renaming. Once Paul pointed out to me that
_[A-Z] and __[a-z] are reserved for the standard library and should
never be used. We use our own namespace so it should be fine, but yet
it became a convention not to start variable names by _[A-Z] and
__[a-z]. Since then, I changed my coding habits.

I think a really sane naming convention for a library is the one
followed by boost.

http://www.boost.org/development/requirements.html#Guidelines

Hey, and they also talk about exceptions (cool)...

http://www.boost.org/development/requirements.html#Exception-specification

...and made me realize I was completely wrong about the good and bad
of exception-specification when it comes to performance.

So I go on to the second point. I also completely agree to remove all
the exception-specifications from the library :)


I'll try to push in the patch today. Otherwise, it'll be next
Thursday. Sorry, quite busy these days...



More information about the libkdtree-devel mailing list