This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH COMMITTED: Don't break tests for enum in range
> Yes, you're right, for some cases VRP could reduce the non-inlined
> version of the test case to "return 1". That couldn't happen for the
> test case I added, though, since C++ defines the range of an enum as
> covering the integer whose numbers of bits is large enough to cover
> all the enum values. So for any enum which does not define 0 as a
> value, a test of this sort can not be reduced to "return 1".
OK, thanks for the explanation. For the records, in Ada this would happen in
most cases without counter-measures.
> If we accept that it is correct that TYPE_PRECISION is not synonymous
> with TYPE_MIN_VALUE and TYPE_MAX_VALUE, then, yes, objects can have
> values outside of their type (isn't that the whole point of
> check'valid, or whatever it is called?).
It is, but we precisely generate counter-measures in Ada because this is
supposed to be a violation of a fundamental assumption of the middle-end...
> I don't really have an opinion on whether this is right or wrong.
> I'll just say that I don't think we should change it unless we first
> produce documentation explaining the middle-end type system and saying
> clearly what the frontend is expected to do. Otherwise we'll just
> wind up having the same argument two years down the road.
Right, we had the same argument two years ago. My understanding is that the
conclusion was not so blurred though.
--
Eric Botcazou