This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Committed: Fix distribute_loop
On Sat, Jan 23, 2010 at 2:37 PM, Paolo Bonzini <bonzini@gnu.org> wrote:
> On 01/23/2010 01:36 PM, Richard Guenther wrote:
>>
>> On Sat, Jan 23, 2010 at 1:30 PM, Joern Rennecke<amylaar@spamcop.net>
>> ?wrote:
>>>
>>> distribute_loop uses the variable "res" to compute the result
>>> before returning it. ?The return type is int, but the variable
>>> res was declared "bool". ?When configuring with
>>> --enable-build-with-cxx, this code is compiled with g++, which
>>> takes bool more seriously; an assignment of 2 to a bool variable
>>> would result in true, binary representation 00000001, so that
>>> the return value would then be 1. ?Therefore, the ldist pass
>>> would not work at all when configuring with --enable-build-with-cxx.
>>>
>>> Fixed with the attached patch.
>>
>> Ugh. ?I wonder if we should use _Bool instead of int
>> if the host compiler supports it.
>
> Then we'd have another share of bugs if someone uses
>
> ?bool a = <something evaluating to 2>;
> ?a &= <something evaluating to 1>;
We do have those already. I run over this recently:
bool all_critical_edge_p = true;
all_critical_edge_p &= e->flags & EDGE_CRITICAL;
with _Bool this would work as expected, with ints it doesn't. With
C++ it would work as well.
Another option would be to stop using bool - as our bool doesn't have
the same semantics as bool in C++ or _Bool in C99. Which can
be surprising.
Richard.