hello, i found there is a return of stack address in function C_alloca located in libiberty/alloca.c step1: initialize "depth" with address of "probe", which is a local variable. step2: store "depth" into "new_storeage" at statement: ((header *) new_storage)->h.deep = depth; step3: return "new_storage" with a offset. can you help me to confirm: 1. is this a return of stack address(or stack address can be manipulated out of the function by subtracting the offset). 2. is the implementation of this function is on purpose?
(In reply to yuxuan He from comment #0) > hello, i found there is a return of stack address in function C_alloca No, you did not. See the definition of XNEWVEC. C_alloca is not what most people understand to be alloca.
actually, i don't mean that XNEWVEC return a stack address, i mean "depth" is stack address and it has been store into new_storage
(In reply to yuxuan He from comment #2) > actually, i don't mean that XNEWVEC return a stack address, i mean "depth" > is stack address and it has been store into new_storage That too is not a problem. Given "char *p = C_alloca (size)", any access outside the range [p, p+size) is undefined behaviour.
ok thanks