MFC's CString class odd behavior
MC -- contem00@CAM.ORG
Sunday, December 15, 1996
Environment: MSVC 4.2b Windows NT 4.0
I'm trying to find out why the following code does what it does...
#include
#include // comment out this line to avoid memory leak
void main(){
CString str(""); // or use str() with no quotes to avoid memory leak
}
/*
Detected memory leaks!
Dumping objects ->
{39} normal block at 0x00420D60, 33 bytes long.
Data: < C > 00 43 00 CD CD CD CD CD CD CD CD CD CD CD CD CD
{38} normal block at 0x00420D10, 40 bytes long.
Data: < @ > A4 E2 40 00 07 00 00 00 00 00 00 00 00 00 00 00
{37} normal block at 0x00420BE0, 256 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete
*/
///////// DTOR can be called explicitly to avoid memory leak ////////
#include
#include
void main(){
CString str(); // This line cannot be str(""); It won't compile with
str.~str; // "error C2274: '->' : illegal as right side of '.' operator"
} // on this line if you try to do so.
Mario Contestabile
mcontest@universal.com
Mast-CBT -- mast@master.csg.it
Wednesday, December 18, 1996
At 20.25 15/12/96 -0500, you wrote:
>
>Environment: MSVC 4.2b Windows NT 4.0
>
>I'm trying to find out why the following code does what it does...
>
>#include
>#include // comment out this line to avoid memory leak
>
>void main(){
> CString str(""); // or use str() with no quotes to avoid memory leak
>}
>
>/*
>Detected memory leaks!
>Dumping objects ->
>{39} normal block at 0x00420D60, 33 bytes long.
> Data: < C > 00 43 00 CD CD CD CD CD CD CD CD CD CD CD CD CD
>{38} normal block at 0x00420D10, 40 bytes long.
> Data: < @ > A4 E2 40 00 07 00 00 00 00 00 00 00 00 00 00 00
>{37} normal block at 0x00420BE0, 256 bytes long.
> Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
>Object dump complete
>*/
>
>///////// DTOR can be called explicitly to avoid memory leak ////////
>#include
>#include
>
>void main(){
>
> CString str(); // This line cannot be str(""); It won't compile with
> str.~str; // "error C2274: '->' : illegal as right side of '.' operator"
>} // on this line if you try to do so.
>
>
>Mario Contestabile
>mcontest@universal.com
>
>
>
>
Change the line
#include
with
#include
I had compiled your code with this change in MSVC 4.0 and I had no problem.
Bye,
--------------------------------------------------
Fabio Saponaro
Context Systems Group - Italian Branch
Magenta (MI)
Tel. ++ 39 2 97298145
Fax ++ 39 2 97298225
http://www.web.csg.it
--------------------------------------------------
| Вернуться в корень Архива
|