X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-stddef.c;h=d7237b3e972b5b9db8b116cfba9ca00df6a123cc;hb=573dad2ce496fa87dac2e79f37bae62e0be1d2c6;hp=f8484987cb3f432009010114e2c3968dd63008cb;hpb=2f5181b1a247323cb2a4a4c6165997674866bb20;p=gnulib.git diff --git a/tests/test-stddef.c b/tests/test-stddef.c index f8484987c..d7237b3e9 100644 --- a/tests/test-stddef.c +++ b/tests/test-stddef.c @@ -1,5 +1,5 @@ /* Test of substitute. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2012 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 @@ -31,8 +31,22 @@ 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 () +main (void) { return 0; }