From 0d28ee458f1847b3c7f3ed810b28b9a988ece40a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 2 Dec 2016 10:22:00 +0000 Subject: [PATCH] type-test: do not rely on signed integer overflow wrapping around Signed integer overflow is undefined behaviour: if a compiler detects signed integer overflow, it is free to compile it to absolutely anything. Signed-off-by: Simon McVittie Bug: https://bugzilla.gnome.org/show_bug.cgi?id=775510 Reviewed-by: Colin Walters --- tests/type-test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/type-test.c b/tests/type-test.c index e767f0f2a..2e91565c7 100644 --- a/tests/type-test.c +++ b/tests/type-test.c @@ -88,15 +88,15 @@ main (int argc, g_assert (gsz == 0); gs = G_MAXSHORT; - gs++; + gs = (gshort) (1 + (gushort) gs); g_assert (gs == G_MINSHORT); gi = G_MAXINT; - gi++; + gi = (gint) (1 + (guint) gi); g_assert (gi == G_MININT); gl = G_MAXLONG; - gl++; + gl = (glong) (1 + (gulong) gl); g_assert (gl == G_MINLONG); /* Test the G_G(U)?INT(16|32|64)_FORMAT macros */