Recently I migrated my application from Visual Studio 2013 to Visual Studio 2015. Everything works fine in DEBUG mode, but if I switch to RELEASE mode this error is popped up: "Unhandled exception at 0x773F7FB2 (ucrtbase.dll) in MyApp.exe: An invalid parameter was passed to a function that considers invalid parameters fatal" (In my application I passed a pointer-to-list). What might be the reason for this error? EDIT: When I used VS 2013 everything worked fine. Isn't it the problem with VS 2015?
-
1Show your code. You might be lucky that it was working before/in debug mode. – Anton Malyshev Aug 24 '16 at 18:45
-
1Probably undefined behaviour, debug the release version of your program. – Richard Critten Aug 24 '16 at 18:46
-
2Usually it means that you're using an uninitialized variable someplace, but it could be almost anything. Debug builds set uninitialized variables to a known value, but Release builds leave it random. – Mark Ransom Aug 24 '16 at 18:46
-
the pointer could be pointing to random memory in release mode, unlike in debug mode, like @MarkRansom suggested. – Arnav Borborah Aug 24 '16 at 18:47
-
1*EDIT: When I used VS 2013 everything worked fine.* -- Looks like VS 2015 exposed a hidden bug in your VS 2013 version of your app . Be thankful. – PaulMcKenzie Aug 24 '16 at 20:02
1 Answers
You should post your code if you want a proper answer. Without it, all I (we) can do is guess.
In any case; there are many differences between release and debug mode. Apart from enabling/disabling optimizations, local variables are often zero initialized (or default initialized) in debug builds, but since that is not mandated by the standard, release builds (optimized ones) don't bother, since it's costly. That's just one example - there are more - but it's the one I'm guessing is biting you.
In any case; it seems your program contains undefined behaviour - which basically means you can't trust it to do anything right, and the optimizing compiler is just exploiting that a lot more than it does in debug mode.
Don't write broken programs containing undefined behaviour! It will bite.

- 30,449
- 3
- 47
- 70