diff options
Diffstat (limited to 'tests/test-stddef.c')
-rw-r--r-- | tests/test-stddef.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/test-stddef.c b/tests/test-stddef.c index bfb72a0..5bd2f78 100644 --- a/tests/test-stddef.c +++ b/tests/test-stddef.c @@ -1,5 +1,5 @@ /* Test of <stddef.h> substitute. - Copyright (C) 2009-2016 Free Software Foundation, Inc. + Copyright (C) 2009-2017 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,13 +12,14 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Eric Blake <ebb9@byu.net>, 2009. */ #include <config.h> #include <stddef.h> +#include <limits.h> #include <stdalign.h> #include "verify.h" @@ -43,9 +44,12 @@ struct d unlikely to bite real code, we ignore that short-coming. */ /* verify (sizeof offsetof (struct d, e) == sizeof (size_t)); */ verify (sizeof (offsetof (struct d, e)) == sizeof (size_t)); -verify (offsetof (struct d, e) < -1); /* Must be unsigned. */ verify (offsetof (struct d, f) == 1); +/* offsetof promotes to an unsigned integer if and only if sizes do + not fit in int. */ +verify ((offsetof (struct d, e) < -1) == (INT_MAX < (size_t) -1)); + /* Check max_align_t's alignment. */ verify (alignof (double) <= alignof (max_align_t)); verify (alignof (int) <= alignof (max_align_t)); |