open-watcom/open-watcom-v2 — pull request #56 by AlexanderMisel (2014-05-24 01:26:00+00:00)
Title: I hope my patch-2 edit can be merged into the hdr of the project.

Got a problem:
```cpp
#include

class BinaryTree
{
typedef char value_type;

struct node
{
value_type data;
node *left, *right;
node(): left(0), right(0) {}
};
public:
BinaryTree(): root(0), count(0) {}

void readTree(const char * storage)
{
c = storage;
root = buildTree(root);
}

void preorder ()
{
return preorder (root);
}
void inorder ()
{
return inorder (root);
}
void postorder()
{
return postorder(root);
}

int height()
{
return height(root);
}
int leaves()
{
return count;
}
private:
node * root;
const char * c;
int count;

int height(node * x)
{
if (!x) return 0;
return 1 + (height(x->left) > height(x->right)
? height(x->left) : height(x->right));
}

node * buildTree(node * x)
{
if (*c == '\0' || *c == '#')
return x;

x = new node;
x->data = *c;

++c;
x->left = buildTree(x->left);
++c;
x->right = buildTree(x->right);

if (!x->left && !x->right) ++count;
return x;
}

//Utilities
void preorder(node * x)
{
if (x)
{
std::cout << x->data << " ";
preorder(x->left);
preorder(x->right);
}
}

void inorder(node * x)
{
if (x)
{
inorder(x->left);
std::cout << x->data << " ";
inorder(x->right);
}
}

void postorder(node * x)
{
if (x)
{
postorder(x->left);
postorder(x->right);
std::cout << x->data << " ";
}
}
};

int main()
{
const char * tree = "ABC#D##E#F##GH##I";
BinaryTree bt;
bt.readTree(tree);
bt.preorder();
std::cout << std::endl;
bt.inorder();
std::cout << std::endl;
bt.postorder();
std::cout << std::endl;

std::cout << "The height of the Binary Tree is "
<< bt.height() << ".\n";
std::cout << "The number of leaves in the tree is "
<< bt.leaves() << ".\n";*/
}
```
This program crashes when running. In MSVC and gcc, no problem is reported. Is my code wrong?