zahed khurasani <sdzahed@xxxxxxxxx> writes: > My check function accepts three parameters: the value being > dereferenced, the size of the object and the address in memory. I am > using the following two lines to get the third address parameter. > > addr = build1 (ADDR_EXPR, build_pointer_type (type), t); // t is the > ARRAY_REF node > fold_convert_loc(location, ptr_type_node, addr); // type case to void * > > However, this is failing whenever the array_ref contains a > non-constant expression, say like a[i+1]. The specific failure is > inside the expand_expr_real_1 method in the file expr.c. Looks like > such non-constant indices are not allowed at this stage in the > compilation (I've inserted the pass just before lowering to RTL > happens). > > My question is, what would be the right way to get the address? I am > looking for something that will preferably work for all dereferences > like MEM_REF, INDIRECT_REF etc. ARRAY_REF certainly permits non-constant indices, so I don't think that is your problem. However, MEM_REF is the most general memory reference expression. Ian