Click here to Skip to main content
15,925,309 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Visual C++ 6 +7 Pin
shultas10-Feb-04 16:11
shultas10-Feb-04 16:11 
GeneralRe: Visual C++ 6 +7 Pin
Tim Smith10-Feb-04 18:19
Tim Smith10-Feb-04 18:19 
GeneralUsing an edit box from other file. Help needed!! Pin
satcat10-Feb-04 12:30
satcat10-Feb-04 12:30 
GeneralSubclassing or Derviving Pin
monrobot1310-Feb-04 12:27
monrobot1310-Feb-04 12:27 
GeneralRe: Subclassing or Derviving Pin
John R. Shaw10-Feb-04 12:49
John R. Shaw10-Feb-04 12:49 
GeneralRe: Subclassing or Derviving Pin
mcsweeneyd10-Feb-04 15:38
mcsweeneyd10-Feb-04 15:38 
GeneralRe: Subclassing or Derviving Pin
monrobot1311-Feb-04 10:04
monrobot1311-Feb-04 10:04 
GeneralStrange memory overrun Pin
John R. Shaw10-Feb-04 10:43
John R. Shaw10-Feb-04 10:43 
I have run into a strange memory overrun problem.Confused | :confused:

Note: The following example code may not reproduce the problem,
they are for illustation only.

Note: There are no compiler errors generated by either of the following
2 cases.

CASE 1: TEST_CTESTCLASS define in Test.cpp file.

Bounds Checker reported an overrun, when my application existed.
The VC++ 6.0 debugger does not show m_pTestClass1 as being a
member of CTestClass2 and yet I can still set it to NULL, with no
complants. If I do not set it to NULL, there is no overrun reported.

Note: The variable type CTestClass2 is declared as a member of a
CScrollView derived class. If the member is removed and made global,
then the overrun is not reported.

// Test.h

#ifndef __TEST_H__
#define __TEST_H__

class CTestClass1
{
	int m_donothing;
public:
	CTestClass() : m_donothing(0) {}
};

class CTestClass2
{
#ifdef TEST_CTESTCLASS
	CTestClass1* m_pTestClass1;
#endif

public:
	CTestClass2();
}

#endif // __TEST_H__


// Test.cpp

#include "stdafx.h"

#define TEST_CTESTCLASS
#include "Test.h"

CTestClass2::CTestClass2()
{
#ifdef TEST_CTESTCLASS
	m_pTestClass1 = NULL;	// causes overrun (~382 bytes)
#endif
}


CASE 2: TEST_CTESTCLASS define in Test.h file.

In case 2 below Bounds Checker reports no overruns and the VC++ 6.0
debugger shows m_pTestClass1 as being a member of CTestClass2.

// Test.h

#ifndef __TEST_H__
#define __TEST_H__

#define TEST_CTESTCLASS

class CTestClass1
{
	int m_donothing;
public:
	CTestClass() : m_donothing(0) {}
};

class CTestClass2
{
#ifdef TEST_CTESTCLASS
	CTestClass1* m_pTestClass1;
#endif

public:
	CTestClass2();
}

#endif // __TEST_H__


// Test.cpp

#include "stdafx.h"
#include "Test.h"

CTestClass2::CTestClass2()
{
#ifdef TEST_CTESTCLASS
	m_pTestClass1 = NULL;	// does not cause overrun
#endif
}


Does anyone have a clue as to what is causing this problem?

Thanks for any hints, etc..., that you can give me.


INTP
GeneralRe: Strange memory overrun Pin
Tom Larsen10-Feb-04 11:30
Tom Larsen10-Feb-04 11:30 
GeneralRe: Strange memory overrun Pin
John R. Shaw10-Feb-04 12:37
John R. Shaw10-Feb-04 12:37 
GeneralRe: Strange memory overrun Pin
Tom Larsen11-Feb-04 5:00
Tom Larsen11-Feb-04 5:00 
QuestionHow to adding "Start parameters" to a Window service Pin
sysmatrix10-Feb-04 10:09
sysmatrix10-Feb-04 10:09 
AnswerRe: How to adding "Start parameters" to a Window service Pin
Peter Weyzen10-Feb-04 11:31
Peter Weyzen10-Feb-04 11:31 
GeneralDoubts with sorting stl vector... Pin
Cloaca10-Feb-04 9:32
Cloaca10-Feb-04 9:32 
GeneralRe: Doubts with sorting stl vector... Pin
David Crow10-Feb-04 10:05
David Crow10-Feb-04 10:05 
GeneralRe: Doubts with sorting stl vector... Pin
Cloaca10-Feb-04 10:14
Cloaca10-Feb-04 10:14 
GeneralRe: Doubts with sorting stl vector... Pin
David Crow10-Feb-04 10:34
David Crow10-Feb-04 10:34 
GeneralRe: Doubts with sorting stl vector... Pin
Cloaca11-Feb-04 6:48
Cloaca11-Feb-04 6:48 
GeneralRe: Doubts with sorting stl vector... Pin
valikac10-Feb-04 10:07
valikac10-Feb-04 10:07 
GeneralRe: Doubts with sorting stl vector... Pin
Cloaca10-Feb-04 10:18
Cloaca10-Feb-04 10:18 
GeneralRe: Doubts with sorting stl vector... Pin
jhwurmbach11-Feb-04 1:51
jhwurmbach11-Feb-04 1:51 
GeneralRe: Doubts with sorting stl vector... Pin
Cloaca11-Feb-04 6:57
Cloaca11-Feb-04 6:57 
GeneralRe: Doubts with sorting stl vector... Pin
antlers11-Feb-04 11:37
antlers11-Feb-04 11:37 
GeneralRe: Doubts with sorting stl vector... Pin
Cloaca12-Feb-04 4:22
Cloaca12-Feb-04 4:22 
Generalfatal crash on win98 & winMe, Need help. Pin
haritadala10-Feb-04 7:43
haritadala10-Feb-04 7:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.