X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-stddef.c;h=2c392c754720e4eeaefcd365d19e2b1c5dd4b450;hb=880d107;hp=d047e57b6566bbd776555591b809bc332f9676cb;hpb=8d8eda4eab3d2801251daf4eb31756c3595e2fc6;p=gnulib.git diff --git a/tests/test-stddef.c b/tests/test-stddef.c index d047e57b6..2c392c754 100644 --- a/tests/test-stddef.c +++ b/tests/test-stddef.c @@ -31,6 +31,20 @@ size_t c = 2; per POSIX 2008. */ verify (sizeof NULL == sizeof (void *)); +/* Check that offsetof produces integer constants with correct type. */ +struct d +{ + char e; + char f; +}; +/* Solaris 10 has a bug where offsetof is under-parenthesized, and + cannot be used as an arbitrary expression. However, since it is + 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); + int main (void) {