I keep getting the above error message for blocks of code that use the assert function and I cannot see why this is. I have searched the Internet for potential answers to this error...without any success.
Below is the aforementioned block of code that throws up this error:
#include <stdio.h>
#include <assert.h>
typedef struct WORD
{
char *Word;
size_t Count;
struct WORD *Left;
struct WORD *Right;
} WORD;
#define SUCCESS 0
#define NO_MEMORY_FOR_WORDNODE 3
#define NO_MEMORY_FOR_WORD 4
int AddToTree(WORD **DestTree, size_t *Treecount, char *Word)
{
int Status = SUCCESS;
int CompResult = 0;
/* safety check */
assert(NULL != DestTree);
assert(NULL != Treecount);
assert(NULL != Word);
/* DestTree is NULL or it isn't */
if(NULL == *DestTree){ /* this is the place to add it then */
*DestTree = malloc(sizeof **DestTree);
if(NULL == *DestTree){
/* out of memory */
Status = NO_MEMORY_FOR_WORDNODE;
}
else {
(*DestTree)->Left = NULL;
(*DestTree)->Right = NULL;
(*DestTree)->Count = 1;
(*DestTree)->Word = dupstr(Word);
if(NULL == (*DestTree)->Word){
/* out of memory in the middle */
Status = NO_MEMORY_FOR_WORD;
free(*DestTree);
*DestTree = NULL;
}
else {
/* everything worked, add one to the tree nodes count */
++*Treecount;
}
}
}
else { /* we need to make a decision */
CompResult = strcmp(Word, (*DestTree)->Word);
if(0 < CompResult){
Status = AddToTree(&(*DestTree)->Left, Treecount, Word);
}
else if(0 > CompResult){
Status = AddToTree(&(*DestTree)->Left, Treecount, Word);
}
else {
/* add one to the count - this is the same node */
++(*DestTree)->Count;
}
} /* end of else we need to make a decision */
return Status;
}
Please note that each one of the assert lines throws up the same error.
I took alk's advice to check the preprocessor outputs and this is what I get:
# 2 "ex6-4.c" 2
# 1 "c:\\mingw\\include\\assert.h" 1 3
# 38 "c:\\mingw\\include\\assert.h" 3
void __attribute__((__cdecl__)) __attribute__ ((__nothrow__)) _assert (const ch
ar*, const char*, int) __attribute__ ((__noreturn__));
# 16 "ex6-4.c" 2`
I have to admit that this makes as much sense to me as the error in question.