summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/pr19606.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.c-torture/execute/pr19606.c')
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr19606.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr19606.c b/gcc/testsuite/gcc.c-torture/execute/pr19606.c
new file mode 100644
index 000000000..d1e836fa0
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr19606.c
@@ -0,0 +1,34 @@
+/* PR c/19606
+ The C front end used to shorten the type of a division to a type
+ that does not preserve the semantics of the original computation.
+ Make sure that won't happen. */
+
+signed char a = -4;
+
+int
+foo (void)
+{
+ return ((unsigned int) (signed int) a) / 2LL;
+}
+
+int
+bar (void)
+{
+ return ((unsigned int) (signed int) a) % 5LL;
+}
+
+int
+main (void)
+{
+ int r;
+
+ r = foo ();
+ if (r != ((unsigned int) (signed int) (signed char) -4) / 2LL)
+ abort ();
+
+ r = bar ();
+ if (r != ((unsigned int) (signed int) (signed char) -4) % 5LL)
+ abort ();
+
+ exit (0);
+}