Click here to Skip to main content
15,891,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: c++ with QT exe file error Pin
Richard MacCutchan13-Aug-13 1:03
mveRichard MacCutchan13-Aug-13 1:03 
GeneralRe: c++ with QT exe file error Pin
Mkhitar_Sargsyan13-Aug-13 1:08
Mkhitar_Sargsyan13-Aug-13 1:08 
GeneralRe: c++ with QT exe file error Pin
Richard MacCutchan13-Aug-13 1:17
mveRichard MacCutchan13-Aug-13 1:17 
GeneralRe: c++ with QT exe file error Pin
Mkhitar_Sargsyan13-Aug-13 1:55
Mkhitar_Sargsyan13-Aug-13 1:55 
QuestionRe: c++ with QT exe file error Pin
David Crow13-Aug-13 4:46
David Crow13-Aug-13 4:46 
AnswerRe: c++ with QT exe file error Pin
leon de boer13-Aug-13 7:02
leon de boer13-Aug-13 7:02 
GeneralRe: c++ with QT exe file error Pin
David Crow13-Aug-13 7:24
David Crow13-Aug-13 7:24 
GeneralRe: c++ with QT exe file error Pin
leon de boer13-Aug-13 10:01
leon de boer13-Aug-13 10:01 
Here let me show you

C++
void silly_error_code (int j){
  const char somearray[5] = {'0','1','2','3','4'};
  char testval;

  testval = somearray[j];
}

int i;

main {
  silly_error_code(i);
}


That code will work fine in debug mode but will most likely crash with the sort of error you have in release mode and the compiler won't pick the error.

WHY ... because variable global variable "i" was never set to any value

When you run in debug mode the compiler zeros all global variables there is a long story of why it does that but for now all you need to do is that it does.

So in debug mode testval will always come back with "0" because i is initialized by the debug mode to 0

In release mode it is highly likely this will crash as "i" could be any value including values which are way outside the array range of somearray.

See how the code above has the same problem as your code ... I can use it safely in debug mode BUT not release.

MICROSOFT TIP: Variables and allocated memory are often initialized differently in Debug versions than in Release version of software. If you've assumed that your variables are zeroed when they are declared could easily cause strange behavior in Release mode on Win9x. You can also introduce bugs that are Win9x specific. WinNT, for security reasons, zeros all memory before it is used.

modified 13-Aug-13 16:12pm.

GeneralRe: c++ with QT exe file error Pin
David Crow13-Aug-13 10:46
David Crow13-Aug-13 10:46 
GeneralRe: c++ with QT exe file error Pin
Mkhitar_Sargsyan13-Aug-13 20:05
Mkhitar_Sargsyan13-Aug-13 20:05 
GeneralRe: c++ with QT exe file error Pin
David Crow14-Aug-13 3:47
David Crow14-Aug-13 3:47 
GeneralRe: c++ with QT exe file error Pin
Mkhitar_Sargsyan14-Aug-13 19:59
Mkhitar_Sargsyan14-Aug-13 19:59 
Questionhow to get hash of account's password Pin
sr333012-Aug-13 19:42
sr333012-Aug-13 19:42 
AnswerRe: how to get hash of account's password Pin
Richard MacCutchan12-Aug-13 20:50
mveRichard MacCutchan12-Aug-13 20:50 
GeneralRe: how to get hash of account's password Pin
sr333013-Aug-13 0:15
sr333013-Aug-13 0:15 
GeneralRe: how to get hash of account's password Pin
Richard MacCutchan13-Aug-13 0:39
mveRichard MacCutchan13-Aug-13 0:39 
AnswerRe: how to get hash of account's password Pin
ngtv12-Aug-13 23:53
ngtv12-Aug-13 23:53 
GeneralRe: how to get hash of account's password Pin
sr333013-Aug-13 0:16
sr333013-Aug-13 0:16 
Questioni'm tring to initialise a sudoku board (9*9) using c++.getting a blank screen with blinking cursor as output. Pin
Member 1019329312-Aug-13 6:47
Member 1019329312-Aug-13 6:47 
AnswerRe: i'm tring to initialise a sudoku board (9*9) using c++.getting a blank screen with blinking cursor as output. Pin
jeron112-Aug-13 6:53
jeron112-Aug-13 6:53 
GeneralRe: i'm tring to initialise a sudoku board (9*9) using c++.getting a blank screen with blinking cursor as output. Pin
Sierra Technical12-Aug-13 7:54
Sierra Technical12-Aug-13 7:54 
QuestionRe: i'm tring to initialise a sudoku board (9*9) using c++.getting a blank screen with blinking cursor as output. Pin
David Crow12-Aug-13 8:00
David Crow12-Aug-13 8:00 
AnswerRe: i'm tring to initialise a sudoku board (9*9) using c++.getting a blank screen with blinking cursor as output. Pin
CPallini12-Aug-13 23:10
mveCPallini12-Aug-13 23:10 
QuestionName of this DesignPattern Pin
AmbiguousName12-Aug-13 1:43
AmbiguousName12-Aug-13 1:43 
AnswerRe: Name of this DesignPattern Pin
Richard MacCutchan12-Aug-13 5:27
mveRichard MacCutchan12-Aug-13 5:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.