mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
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:
parent
4496ef91b5
commit
0d28ee458f
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user