From 6c9e1cb25102e3d5d2b67c2a18e7563d3c04ec8b Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Sun, 19 Jul 1992 01:09:39 +0000 Subject: [PATCH] (build_binary_op): Don't set shorten for signed division. From-SVN: r1623 --- gcc/c-typeck.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 42d2be0686d..7b9342914a1 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2283,7 +2283,9 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) if (!(code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)) resultcode = RDIV_EXPR; else - shorten = 1; + /* When dividing two signed integers, you have to promote to int. + E.g. (short) -32868 / (short) -1 doesn't fit in a short. */ + shorten = TREE_UNSIGNED (op0); common = 1; } break; -- 2.30.2