Re: declaration of variable in for loop
- From: santosh <santosh.k83@xxxxxxxxx>
- Date: Thu, 31 Jan 2008 15:19:04 +0530
jacob navia wrote:
<snip>
main()
{
int i,j, *pint;
for(i=0;i<10;i++){
int k = i;
printf("%d %p = *%d\n",i,&k,k);
pint=&i;
}
*pint = 789; // Accessing illegal storage
}
This would work on lcc-win since the storage is still valid.
I would not do this since it is absolutely non portable.
Other compilers could implement other strategies.
I hope as a QoI issue lcc-win issues a diagnostic for such uses?
<snip>
.
- Follow-Ups:
- Re: declaration of variable in for loop
- From: Flash Gordon
- Re: declaration of variable in for loop
- References:
- declaration of variable in for loop
- From: poornimamprabhu
- Re: declaration of variable in for loop
- From: jacob navia
- declaration of variable in for loop
- Prev by Date: Re: xmalloc string functions
- Next by Date: Re: A solution for the allocation failures problem
- Previous by thread: Re: declaration of variable in for loop
- Next by thread: Re: declaration of variable in for loop
- Index(es):
Relevant Pages
|