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 <smcv@debian.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=775510
Reviewed-by: Colin Walters
This commit is contained in:
Simon McVittie 2016-12-02 10:22:00 +00:00
parent 4496ef91b5
commit 0d28ee458f

View File

@ -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 */