I have written a program in Visual C++ Express. I have finally finished and that's why I wanted a release version of my program. To give to some of my friends.
There was no problem when I used the compiler to create the debug version. But when I run the release version it gives me an error after having run a while.
I get this error:
Unhandled exception at 0x67313482 (msvcp100.dll) in test.exe: 0xC0000005: Access violation reading location 0x00000005.
It stops working at this return.

dateorder __CLR_OR_THIS_CALL date_order() const
		{	// return date order code
		return (do_date_order());
		}

I haven't been calling this function directly. I have no idea why this would be used.
I am just a starting programmer and this is the first time I've used Visual C++. So it might be a beginners mistake. Hopefully I can fix this easily.
I tested it on win7 32bit and win7 64bit and both had this problem.

Edit: when it stops Visual studio says this is the value of _Days , _Monts and _Dateorder :
CXX0030: Error: expression cannot be evaluated.

Edited 5 Years Ago by Jelte12345: n/a

I doubt it's a problem with your code since it runs properly in Debug mode. Is there a section of code in your program that deals with either localization, dates or times? It may be a good idea to post that section for review and comment.

It's also possible, depending on what features you are trying to use, that it's a limitation of the Express Edition. Unfortunately, I don't know enough about those limitations to help with that.

Edited 5 Years Ago by Fbody: n/a

But when I run the release version it gives me an error after having run a while.

Not only is your bug dependent on debug vs. release, it's also intermittent (as I understand from "having run a while"). How large is the code base? Are you able and willing to post the code if it's not too big? These kinds of errors are somewhat difficult to troubleshoot with the ol' crystal ball.

I doubt it's a problem with your code since it runs properly in Debug mode.

Oh, if only that were the case. Sadly, some bugs only manifest outside the relative safety of debug mode. Equally sadly, those bugs are usually assigned to me...

Edited 5 Years Ago by Narue: n/a

I doubt it's a problem with your code since it runs properly in Debug mode. Is there a section of code in your program that deals with either localization, dates or times? It may be a good idea to post that section for review and comment.

As far as I know my program doesn't use any of these. It just needs do a lot of the same calculations with different variables. And it writes the answers to those to a file. The whole program is console based btw.

It's also possible, depending on what features you are trying to use, that it's a limitation of the Express Edition. Unfortunately, I don't know enough about those limitations to help with that.

I don't think this would be a very logical explanation, since the program doesn't use very complicated stuff.
The only libraries I have included are these:

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>

Edit:

How large is the code base? Are you able and willing to post the code if it's not too big? These kinds of errors are somewhat difficult to troubleshoot with the ol' crystal ball.

Big is sort of relative, but the size of the .cpp is 26kb and I'm willing to post the code if anyone is willing to read through it.
At the moment I don't have a lot of comments in it though and most of the ones that I have are Dutch.

Edited 5 Years Ago by Jelte12345: n/a

I am just a starting programmer and this is the first time I've used Visual C++. So it might be a beginners mistake. Hopefully I can fix this easily.

Ok, I found out it was a beginners mistake. It has been working without errors for five minutes now, instead of a couple of seconds, which makes me quite certain that it works.
I googled some more for differences between release and debug builds. And I found out I had to initialize all the variables. So I initialized all my used ints as 0 at the point where I declared them. And now it works.

This question has already been answered. Start a new discussion instead.