The information in this article applies to:
SYMPTOMSUsing the new operator to dynamically allocate memory for a typedef pointer to a class member function that has return type void will allocate 0 (zero) bytes for the function pointer. STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. MORE INFORMATION
When typecasting a pointer to a class member function that returns type
void and trying to dynamically allocate pointers to this user defined type,
the compiler allocates 0 (zero) bytes. This can best be seen by generating a
mixed source/assembly language listing file using the /Fc compiler option
and observing that the new operator is passed 0 bytes as the amount of
memory to allocate. Using the sample code below, the following is the
source/assembly listing for the call to new:
This problem occurs only when using a return type of void for the typedef
pointer to class member function. Any other return type causes the proper
amount of memory to be allocated by the new operator.
To work around this problem, allocate an array of chars using the sizeof() keyword to cause the new operator to allocate the proper number of bytes. The returned pointer will need to be typecast to the proper type. The following code sample demonstrates the problem and workaround: Sample Code
Additional query words:
Keywords : kbVC400bug kbVC500bug kbVC600bug |
Last Reviewed: February 2, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |