At 9:30 -0700 22/9/04, Scott Moore wrote:
The problem is, that using variables may only delay the problem:
procedure dummy(x, y: integer);
var a: integer;
begin
a := x; a := y
end;
(or similar), would work today, then tomorrow when the compiler gets better dead code elimination, it figgures out that a isn't used for anything, and you are back to getting the warning.
Actually, this already happens with MW Pascal, if you turn up the optimization level the warnings would come back for that case.
There is also the negative case where the parameter being ignored is a var large record/array, and thus unless the optimization works that results in lots of wasted stack space (potentially stack overflowing in fact) and CPU time (although you can then convert to junk := r.field or junk := a[1], further obscuring the purpose of the code).
IP Pascal uses: reference(x);
Which is straightforward. Reference is a built-in that sets the variable as referenced.
Nice. I'm happy with that as a GPC solution (it looks similar to what Frank was after, and we might as well be compatible with something as make up something new). I'll still need the {$unused(x,y,z)} either supported or ignored for compatibility.
Enjoy, Peter.