Re: bug in visual studio .net 2003 - breakpoints and memcpy



Alexander Grigoriev wrote:
> According to ANSI C and standard C++, there is no standard conversion
> from a function pointer to void*, and vice versa. It's just not
> listed among the possible conversions.

Sounds like "undefined by omission" to me. Unless the standards explicitly
forbid what is not allowed (I don't have copies to check). In any case even
if the standards explicitly disallowed such casts this would be just a case
of useless and pointless standard restriction. If it works on certain
platforms but not others the behavior should be undefined.

> A function pointer can be
> converted to an integer of an appropriate size, though, which you may
> (or may not) be able then convert to a void* (the size of the
> necessary integer may be different from the required void* size).

Now this is something I would definitely avoid doing. If a direct cast works
it works. Otherwise the conversion is an error and the "double cast" doesn't
help.


--
Eugene
http://www.gershnik.com


.



Relevant Pages

  • Casting pointers to functions of different types
    ... It has to cast a function pointer to some ... Code which stored function pointer in array of unsigned ... typedef void; ... void marshal (AFunc func, int *args) ...
    (comp.lang.c)
  • Re: Plugins as game data
    ... Once you have the address of the function, cast it using a function ... // cast your void * address into the right function pointer ... you do not need to use the varargs stuff. ...
    (rec.games.roguelike.development)
  • Re: functions pointer
    ... void *; ... [I'll ignore whether this is worthy of posting to comp.std.c] ... The standard doesn't provide a generic function pointer type, ... it allows explicit conversions from any function pointer type ...
    (comp.std.c)
  • Re: Plugins as game data
    ... Once you have the address of the function, cast it using a function ... // cast your void * address into the right function pointer ... somefunction(fmt, vp); ...
    (rec.games.roguelike.development)
  • Re: Plugins as game data
    ... Once you have the address of the function, cast it using a function ... // cast your void * address into the right function pointer ... Assuming that all data types involved in the function call are ...-friendly, ...
    (rec.games.roguelike.development)