Heap Corruption using MSVC (found the issue)

Jot Dot <[email protected]>
Newsgroups gmane.comp.parsers.bison.bugs
Message-ID <[email protected]>
re: Posting in help-bison, same topic

I have isolated the problem with my code.
If (in my .y file) I do not have this defined:

%define parse.trace

then I get a heap corruption error.
By simply adding that line, the corruption disappears.

Attached is a heavily chopped down MSVC solution that demonstrates it.
The entire main program (in test.cpp) is simply:

#include <stdio.h>

#include "driver.h"
#include "scanner.h"

int main(int argc, char* argv[])
{

	Driver driver;

	gen::Parser* pParser = new gen::Parser(&driver);

	// Heap corruption when the .y file does not have %define parse.trace
	// If we add the define, the corruption disappears
	delete pParser; // <<<=== Heap corruption detected

	return 0;
}
test.zip (application/zip, 48.8 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.