Click here to Skip to main content
16,005,178 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: some strange error Pin
Hamid_RT13-Feb-07 8:18
Hamid_RT13-Feb-07 8:18 
GeneralRe: some strange error Pin
Mark Salsbery13-Feb-07 8:27
Mark Salsbery13-Feb-07 8:27 
GeneralRe: some strange error Pin
thesad13-Feb-07 8:39
thesad13-Feb-07 8:39 
GeneralRe: some strange error Pin
Mark Salsbery13-Feb-07 8:50
Mark Salsbery13-Feb-07 8:50 
AnswerRe: some strange error Pin
Christian Graus13-Feb-07 8:42
protectorChristian Graus13-Feb-07 8:42 
QuestionMFC tips Pin
Alessandra7713-Feb-07 6:18
Alessandra7713-Feb-07 6:18 
AnswerRe: MFC tips Pin
Maximilien13-Feb-07 6:38
Maximilien13-Feb-07 6:38 
GeneralRe: MFC tips Pin
Stephen Hewitt13-Feb-07 11:13
Stephen Hewitt13-Feb-07 11:13 
Maximilien wrote:
check that all pointers are valid before using them.

 
I'm of the opinion that that is a bad idea. For example, consider code that follows the following pattern throughout:
if (p)
{
    p->SomeFunction();
}


Many people (most people, in fact) get into the habit of doing this even when it is a bug for p to be NULL. Assuming p should never be NULL the extra check turns a crash at the point of the problem into some obscure problem later down the track as the function SomeFunction was never called. I’ve seen this many, many times. A better approach is as follows:
assert(p);
p->SomeFunction();


In a debug build we assert and in a release build you get a crash dump (because naturally everyone collects crash dumps from MS…) which points you at the problem.

As for IsBadReadPointer and friends, see here[^].


Steve

GeneralRe: MFC tips Pin
Maximilien13-Feb-07 14:09
Maximilien13-Feb-07 14:09 
AnswerRe: MFC tips Pin
Mark Salsbery13-Feb-07 6:53
Mark Salsbery13-Feb-07 6:53 
AnswerRe: MFC tips Pin
toxcct13-Feb-07 7:05
toxcct13-Feb-07 7:05 
AnswerRe: MFC tips Pin
Hamid_RT13-Feb-07 7:15
Hamid_RT13-Feb-07 7:15 
AnswerRe: MFC tips Pin
Alessandra7713-Feb-07 8:58
Alessandra7713-Feb-07 8:58 
GeneralRe: MFC tips Pin
Hamid_RT13-Feb-07 17:23
Hamid_RT13-Feb-07 17:23 
Questionwhat if the server has a unix os Pin
prithaa13-Feb-07 5:40
prithaa13-Feb-07 5:40 
AnswerRe: what if the server has a unix os Pin
toxcct13-Feb-07 5:57
toxcct13-Feb-07 5:57 
GeneralRe: what if the server has a unix os Pin
prithaa13-Feb-07 18:21
prithaa13-Feb-07 18:21 
Question64 bit compile problems [modified] Pin
Mike Curry - Canada13-Feb-07 5:08
Mike Curry - Canada13-Feb-07 5:08 
QuestionRe: 64 bit compile problems Pin
David Crow13-Feb-07 5:11
David Crow13-Feb-07 5:11 
AnswerRe: 64 bit compile problems Pin
Mike Curry - Canada13-Feb-07 5:16
Mike Curry - Canada13-Feb-07 5:16 
QuestionRe: 64 bit compile problems Pin
David Crow13-Feb-07 5:24
David Crow13-Feb-07 5:24 
AnswerRe: 64 bit compile problems Pin
Mike Curry - Canada13-Feb-07 5:30
Mike Curry - Canada13-Feb-07 5:30 
AnswerRe: 64 bit compile problems Pin
Chris Losinger13-Feb-07 5:16
professionalChris Losinger13-Feb-07 5:16 
AnswerRe: 64 bit compile problems Pin
Waldermort13-Feb-07 6:56
Waldermort13-Feb-07 6:56 
QuestionWeb Service Authentication Problem Pin
xelontr13-Feb-07 4:13
xelontr13-Feb-07 4:13 

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.