This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/19293] avr-gcc crashes when using shifts with negative shift count
- From: "bjoern dot m dot haase at web dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Jan 2005 17:35:11 -0000
- Subject: [Bug target/19293] avr-gcc crashes when using shifts with negative shift count
- References: <20050106160127.19293.bjoern.m.haase@web.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bjoern dot m dot haase at web dot de 2005-01-06 17:35 -------
It seems that the standard says that shift operations with negative shift count
are supposed to yield an "unspecified" result.
Is there some more specific convention for gcc on how to behave in these cases?
Otherwise the only thing to do would be to fix the instruction length
calculation in the back-end code.
Copy from C-Standards description:
http://www.open-std.org/jtc1/sc22/open/n2794/n2794.txt
6.5.7 Bitwise shift operators
Syntax
[#1]
shift-expr:
additive-expr
shift-expr << additive-expr
shift-expr >> additive-expr
Constraints
[#2] Each of the operands shall have integer type.
Semantics
[#3] The integer promotions are performed on each of the
operands. The type of the result is that of the promoted
left operand. If the value of the right operand is negative
or is greater than or equal to the width of the promoted
left operand, the behavior is undefined.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19293