I have a C++ program (GCC) and when I add one or more int members to an abstract base class, the program starts crashing. In the case I’ve examined, it seems that by adding this member, a member in a derived class quits getting initialized (or gets stomped on at some point). If I add more members, it starts (not) working different. This is all really odd because the member is never used anywhere. I can comment out that one line and the program recompile just fine and runs without error.
The whole program is ~3KLOC and would be very hard to strip down.
I’m totally at a loss as to where to start looking. Any Ideas?
Update
I found the issue: free-ing malloc-ed memory and delete-ing new-ed memory is not safe in the same program.
Off the top of my head, without seeing any code (see comments on your question) I would suggest a rogue pointer which normally stomps on something you don’t notice, but introducing a new member makes it stomp on something you do notice.
Try adding members of different sizes, or more (unused)
intmembers, or maybe a string in the form:const char xxx[50];to reserve more space.