|
-
June 23rd, 2008, 02:02 AM
#1
Not dropping core when referring out of bound address...
Here's my prog running on solaris10.
Code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct ThshldActionStat
{
char thshldAction[25];
};
const int MAX_THSHLDS_PER_GRP_CD = 50;
typedef ThshldActionStat ThshldGroupActions[MAX_THSHLDS_PER_GRP_CD];
int main()
{
ThshldGroupActions *thshldGroupActionStatsOver_;
ThshldGroupActions *thshldGroupActionStatsUnder_;
thshldGroupActionStatsOver_ = new ThshldGroupActions[55 + 1];
thshldGroupActionStatsUnder_ = new ThshldGroupActions[55 + 1];
int i,j;
for ( i=0;i<59;i++ )
for(j=0;j<67;j++)
{
strcpy( thshldGroupActionStatsOver_[i][j].thshldAction, "" );
strcpy( thshldGroupActionStatsUnder_[i][j].thshldAction, "" );
}
return 0;
}
It is running fine... which should drop core in general....
Can some one please help me here to say what's happening here?
Thx in advance!
Last edited by Ejaz; June 23rd, 2008 at 07:27 AM.
Reason: Code tags added
-
June 23rd, 2008, 02:46 AM
#2
Re: Not dropping core when referring out of bound address...
the behavior in this case is undefined. It may or may not crash.. If you are lucky then it crashes
Wakeup in the morning and kick the day in the teeth!! Or something like that.
"i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."
-
June 23rd, 2008, 03:49 AM
#3
Re: Not dropping core when referring out of bound address...
 Originally Posted by games_icon
It is running fine... which should drop core in general....
Welcome to the world of 'C' programming, where writing beyond the boundaries of an array can do *anything*.
The program may work all the time, it may crash all the time, it may work sometimes and crash other times, it may work all the time on one machine, and crash all the time on another machine, etc...
As a matter of fact, there is nothing in the 'C' or C++ language definition that guarantees any code to crash -- in C++, you have exceptions, but that is still a language construct.
Regards,
Paul McKenzie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|