| View previous topic :: View next topic |
| Author |
Message |
sg57
Joined: 14 Oct 2005 Posts: 154
|
Posted: Tue Aug 08, 2006 8:07 am Post subject: How many levels of re-direction until stack space runs out? |
|
|
I'm just curious, since we can point to pointers, how many levels of this re-direction can the compilier take before it runs out of stack space? Here is an example...
| Code: |
int i = 3;
int* pi = &i;
int** p2i = π
int*** p3i = &p2i;
int**** p4i = &p3i;
int***** p5i = &p4i;
int****** p6i = &p5i;
int******* p7i = &p6i;
int******** p8i = &p7i;
int********* p9i = &p8i;
int********** p10i = &p9i;
int*********** p11i = &p10i;
int************ p12i = &p11i;
int************* p13i = &p12i;
int************** p14i = &p13i;
int*************** p15i = &p14i;
int**************** p16i = &p15i;
int***************** p17i = &p16i;
int****************** p18i = &p17i;
int******************* p19i = &p18i;
int******************** p20i = &p19i;
int********************* p21i = &p20i;
int********************** p22i = &p21i;
int*********************** p23i = &p22i;
int************************ p24i = &p23i;
int************************* p25i = &p24i;
int************************** p26i = &p25i;
int*************************** p27i = &p26i;
int**************************** p28i = &p27i;
int***************************** p29i = &p28i;
int****************************** p30i = &p29i;
int******************************* p31i = &p30i;
int******************************** p32i = &p31i;
int********************************* p33i = &p32i;
| I'm sure it would slow down any application using such a mass amount of re-direction if it did compile... So could i get an estimate? 3,000?
Last edited by sg57 on Tue Aug 08, 2006 8:13 am; edited 1 time in total |
|
| Back to top |
|
 |
groepaz

Joined: 01 Sep 2005 Posts: 305
|
Posted: Tue Aug 08, 2006 8:12 am Post subject: |
|
|
i would think that its hard to give a general answer to this, it would heavily depend on how those pointers are actually used :)
but it could be an interisting experience to both write and later read some code that uses such stuff in a non trivial way :) _________________ http://www.hitmen-console.org
http://hitmen.c02.at/files/yapspd/ |
|
| Back to top |
|
 |
sg57
Joined: 14 Oct 2005 Posts: 154
|
Posted: Tue Aug 08, 2006 8:15 am Post subject: |
|
|
I dont really see an easy way, unless you, by hand, type it all up to 3,000 or however many...
Unless you make an array of pointers, all pointing to the element below them... In theory... |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Tue Aug 08, 2006 8:22 am Post subject: |
|
|
| Dereferencing pointers has nothing to do with the stack. You could dereference pointers all day if you felt like it. The only issue is that you actually need to store the pointers somewhere, so the limit would be the amount of RAM you have available. |
|
| Back to top |
|
 |
|