DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2308
Version: 1.3.0


@Greg: Yes, of course your code version works, because you are always
accessing (reading) the union in the same way as you stored the value. But
you're missing the point that I wrote above: the callback *always* uses the
full user_data_ value and calls the callback function with this as the
second argument. If sizeof(long) < sizeof(void*) in your code, then the
extraneous part in the void* part of the union is undefined. Accessing it
via the argument() method is okay, but if we would call the callback via
callback_(Fl_Widget *, user_data_), then that undefined part would be used
in calling the callback. This *might* be okay as long as the callback is
defined as my_callback(Fl_Widget*, long), but what if it is defined as
my_callback(Fl_Widget*,void *v), and the code casts the given argument
like "long my_arg = (long)v" ? What if the same is done on a big-endian
and on a little-endian machine?

Please understand me right: I don't want to say that it wouldn't work in
some or all cases as expected, but we would enter the gray zone of
undefined (maybe implementation-dependent) behaviour of the code. At
least...


Link: http://www.fltk.org/str.php?L2308
Version: 1.3.0

_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to