This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Type conversion and addition
> This is of course a definition of C semantics rather than tree semantics,
> but I believe our trees follow the C semantics here.
Not quite, TREE_OVERFLOW is set on the result. And the C front-end has
explicit code to unset it:
build_c_cast:
/* Ignore any integer overflow caused by the cast. */
if (TREE_CODE (value) == INTEGER_CST)
{
if (CONSTANT_CLASS_P (ovalue)
&& (TREE_OVERFLOW (ovalue) || TREE_CONSTANT_OVERFLOW (ovalue)))
{
/* Avoid clobbering a shared constant. */
value = copy_node (value);
TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
TREE_CONSTANT_OVERFLOW (value) = TREE_CONSTANT_OVERFLOW (ovalue);
}
else if (TREE_OVERFLOW (value) || TREE_CONSTANT_OVERFLOW (value))
/* Reset VALUE's overflow flags, ensuring constant sharing. */
value = build_int_cst_wide (TREE_TYPE (value),
TREE_INT_CST_LOW (value),
TREE_INT_CST_HIGH (value));
}
void foo ()
{
int x = (int) (unsigned int) (int) (-1);
}
--
Eric Botcazou