This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR19100: truthvalue_conversion vs. TREE_CONSTANT_OVERFLOW

Roger Sayle wrote:
The following patch is a fix to PR middle-end/19100 which is a serious
wrong code bug in the C family front-ends.  The problem is that the
routine c_common_truthvalue conversion assumes that any INTEGER_CST
that isn't integer_zerop must be integer_nonzerop.  Unfortunately, this
assumption falls foul of TREE_CONSTANT_OVERFLOW, where if a constant
has previously overflowed during constant folding both integer_zerop
and integer_nonzerop return false.

I have a broader question. In C, where signed overflow is implementation-defined behavior, why don't we just define it to wrap, as with unsigned arithmetic, in the usual modulo-2 way. And then not set TREE_CONSTANT_OVERFLOW at all? What do we want with nodes that are zero, but marked as having overflowed?

Whilst I was there I also noticed two further problems in the cases
directly before and after in c_common_truthvalue_conversion. We
were not only also ignoring TREE_CONSTANT_OVERFLOW for REAL_CSTs,
but also return "true" for NaN.

That part of the patch seems non-controversial.

> And in the Boolean comparison
cases, we were destructively modifying the tree in-place (which in
the middle-end is generally considered a bad thing).

Have you measured the memory impact of this change?

whilst updating the dependencies for c-common.o, I
noticed that there were already several missing header file
dependencies, with are also fixed below.

Clearly OK.


Mark Mitchell
CodeSourcery, LLC
(916) 791-8304

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]