On Mon, 21 Nov 2005, Giovanni Bajo wrote:
I didnt get your point. I am allocating space only for 400 inregers
then as soon as in the loop if it crosses the value of 400 , it should
have given a segementation voilation ?
No. For that to happen, you need some memory checker. GCC has -fmudflap, t
Sandeep Kumar <[EMAIL PROTECTED]> wrote:
> I didnt get your point. I am allocating space only for 400 inregers
> then as soon as in the loop if it crosses the value of 400 , it should
> have given a segementation voilation ?
No. For that to happen, you need some memory checker. GCC has -fmudflap,
On 11/20/05, Andrew Pinski <[EMAIL PROTECTED]> wrote:
> >
> > Hi Everyone,
> >
> > int
> > main ()
> > {
> > int *p;
> > int i;
> >
> > p = (int *) malloc (400 * sizeof (int));
> > for (i = 0; i < 512; i++)
> > {
> > p[i] = i;
> > printf ("p[%d]: %d\n", i, p
On 11/20/05, Andrew Pinski <[EMAIL PROTECTED]> wrote:
> > > Second you are invoking undefined behavior by accessing passed the array
> > > bounds (or allocated
> > > bounds by malloc).
> >
> > I didnt get your point. I am allocating space only for 400 inregers
> > then as soon as in the loop if it
> > Second you are invoking undefined behavior by accessing passed the array
> > bounds (or allocated
> > bounds by malloc).
>
> I didnt get your point. I am allocating space only for 400 inregers
> then as soon as in the loop if it crosses the value of 400 , it should
> have given a segementatio
>
> Hi Everyone,
>
> int
> main ()
> {
> int *p;
> int i;
>
> p = (int *) malloc (400 * sizeof (int));
> for (i = 0; i < 512; i++)
> {
> p[i] = i;
> printf ("p[%d]: %d\n", i, p[i]);
> }
>return 0;
> }
>
> The following code should terminate wit
Hi Everyone,
int
main ()
{
int *p;
int i;
p = (int *) malloc (400 * sizeof (int));
for (i = 0; i < 512; i++)
{
p[i] = i;
printf ("p[%d]: %d\n", i, p[i]);
}
return 0;
}
The following code should terminate with Segmentation fault, right ?
But when