This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Question about precise definition FLOOR_MOD_EXPR
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: gcc at gcc dot gnu dot org
- Date: Sun, 1 Aug 04 21:31:31 EDT
- Subject: Question about precise definition FLOOR_MOD_EXPR
What should the result of <FLOOR_MOD_EXPR 11 -5> be?
There is recent code added to fold that says that the negation can be ignored
so this should be 1.
However, if the "-5" is a variable and you let it be evaluated at runtime,
the result is -4.
I think it's a bad idea that folding produces a different result than
executing the computation at run-time.
Moreover, what *is* the result supposed to be? The Ada standard is clear
that it should be -4. From looking at the online version of the C
standard, I can't tell whether 1, -4 or choosing either at random is
a valid result. Does anybody know? How about C++? Java? Does this
come up in Fortran?