This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gnu software bugs - shift left
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Mischa Baars <mjbaars1977 at gmail dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, Ian Lance Taylor <iant at google dot com>
- Date: Sat, 2 Nov 2013 19:17:11 +0000
- Subject: Re: gnu software bugs - shift left
- Authentication-results: sourceware.org; auth=none
- References: <527535B8 dot 9070903 at gmail dot com> <CAPF-yOY7Zmvftk7FKdKSOuE6=LLyRV50SyptuD9BcKr7Lso2Sw at mail dot gmail dot com> <527544F2 dot 40405 at gmail dot com> <CAKOQZ8xQShp9ofuBEhn7khQNokyPuDaGaVqra4DiA3wHs9hi2Q at mail dot gmail dot com> <52754B34 dot 2000901 at gmail dot com>
On 2 November 2013 18:57, Mischa Baars wrote:
>
> I understand, however it seems more logical to use the destination type to
> determine the type of the first and second operand.
>
> Are you completely sure this is the desired behaviour?
It's the behaviour required by the C standard, so yes, it is
absolutely desirable that GCC does that.
The literal 1 has a fixed type and the literal 31 has a fixed type,
and the expression (1<<31) has a fixed type. Whether you assign the
result to a different type does not alter those types involved in the
expression.