Patch to projects.html: glibc's string function macros
Joseph S. Myers
jsm28@cam.ac.uk
Mon Oct 30 13:51:00 GMT 2000
On Mon, 30 Oct 2000, Kaveh R. Ghazi wrote:
> Oops. :-)
>
> The existing stdio optimization, fputs("", stream) -> NOP, won't
> currently evaluate `stream' if the transformation is successfuly
> applied, and I guess this is exactly what you meant, e.g. if `stream'
> is `foo++'.
>
> I noticed that expand_builtin_va_end() evaluates to NOP but makes an
> effort to evaluate its argument by doing:
>
> > if (TREE_SIDE_EFFECTS (valist))
> > expand_expr (valist, const0_rtx, VOIDmode, EXPAND_NORMAL);
> > [...]
> > return const0_rtx;
fputs certainly should be fixed. I've asked comp.std.c about the
requirements for evaluation exactly once of arguments of the <stdarg.h>
macros - which aren't totally clear - but as a quality of implementation
issue at least, the arguments should be evaluated exactly once.
You should add testcases (to gcc.c-torture/execute, I guess) for both the
va_end and the fputs cases when you fix them. Given the slightly odd
nature of both va_lists and FILE pointers, you probably want the
expression with side effects to be something involving an array of
va_lists (or pointers to va_lists) or pointers to FILE, with an index or
pointer that should get incremented.
--
Joseph S. Myers
jsm28@cam.ac.uk
More information about the Gcc-patches
mailing list