That C parser bug

Charles M. Hannum root@ihack.net
Fri Oct 30 12:17:00 GMT 1998


So I have a little more info.

It appears that any statement of the form:
  *foo++ = bar ? baz : qux;
(where `baz' and `qux' are simple types) will lose.

What happens is this:

Because the subexpressions of the conditional are simple types,
expand_expr() pushes the store into the subexpressions, rather than
using a temp register.  It therefore returns the rtx of the memory
location rather than a temp.

store_expr() [line 3341], realizing that it needs to use the value
again, uses copy_to_reg() to emit a move insn to copy the value back
out of memory.  This move insn is inserted *in the wrong place*, and
therefore fetches the old value from memory.  This is the bug.

store_expr() [line 3460] then proceeds to forget that the value was
already stored in memory, and emits another move insn to copy it back
from the register.  This is not per se a bug, but will generate
suboptimal code.




More information about the Gcc-bugs mailing list