On Fri, Nov 09, 2007 at 12:47:03AM +0100, Chris Brody-GMail <[EMAIL PROTECTED]> 
wrote:
> tests on OSX. In addition, all test from eventxx were working except
> for bench.cpp, which uses a strange copy constructor, and priority

I didn't find anything related to a copy constructor on glancing over the
source, but eventxx
(http://git.llucax.com.ar/?p=software/eventxx.git;a=blob;f=eventxx;h=7b4d950d087255d735fb7a550f32d8b0a8fd0d21;hb=HEAD)
has some deep problems:

 203         int r = static_cast< int >(t1) | static_cast< int >(t2);
 204         int* pr = &r; // Avoid some weird warning about dereferencing
 205                       // type-punned pointer will break strict-aliasing 
rules
 206         return *reinterpret_cast< type* >(pr);

here it assumes that "type" has the same representation as an int, which
isn't true in general but at least common enough. and the warning is
actually hinting at another problem: the compiler may assume that the type
* does not point to pr by language rules (and newer gcc versions take
advantage of this in more and more cases).

much worse:

 325                         short* pev = &ev; // Avoid some weird warning about
 326                                           // dereferencing type-punned 
pointer
 327                                           // will break strict-aliasing 
rules
 328                         handler(fd, *reinterpret_cast< type* >(pev));

here it assumes that "type" (which afaics is the same enum as above)
has the same representation as a short (ev is actually short), and the
aliasing rule applies too.

it cannot be both int and short, in general.

most likely, this works only by chance and only on little-endian architectures.

regarding copy constructors, if used, and I don't see where in bench.cpp
it would use them, but it is entirely possible, it would break stuff, as
the compiler-synthesized copy constructor will not do the right thing for
either libevent or libev for active watchers. the best way would be to
make it private without implementing it, or using stop/start.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      [EMAIL PROTECTED]
      -=====/_/_//_/\_,_/ /_/\_\
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users

Reply via email to