This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Re: c/7284: incorrectly simplifies leftshift followed by signed power-of-2 division
- From: "Al Grant" <AlGrant at myrealbox dot com>
- To: nathan at compsci dot bristol dot ac dot uk
- Cc: falk dot hueffner at student dot uni-tuebingen dot de,nathan at gcc dot gnu dot org,algrant at acm dot org,gcc-bugs at gcc dot gnu dot org,gcc-prs at gcc dot gnu dot org,nobody at gcc dot gnu dot org,gcc-gnats at gcc dot gnu dot org
- Date: Fri, 12 Jul 2002 17:06:44 +0000
- Subject: Re: Re: c/7284: incorrectly simplifies leftshift followed by signed power-of-2 division
>you need to read more carefully.
>KnR 2 A7.8 says the same as C99,
You need to read more carefully. K&R2 says something quite different from C99. It says that in the absence of overflow, the operation is equivalent to a
multiplication. It does _not_ say that if the multiplication overflows the result of the shift is undefined, let alone that program behavior is undefined.
>C++ says [5]/5 that if the result is not in the range >of representable values,
>the behaviour is undefined.
But left-shift is an operation on the representation, i.e. the bit pattern. For signed left-shift (in C89 and C++) it is not defined any other way. How is it meaningful to talk about the representability of operations on the representation, and say that the result of such an operation might be unrepresentable?
Representability is a property of the integers as numbers.
It might be meaningful to think about the result of such an operation having a representation that did not correspond to any value (e.g. was a trap representation) but a non-valued representation is a totally different concept from a non-representable value. Besides, there are no such integer representations on the platform for which I reported the bug.