Re: Compilation warning on offsetof in 5.4 and trunk

From: Date: Sun, 03 Jul 2011 01:27:16 +0000
Subject: Re: Compilation warning on offsetof in 5.4 and trunk
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-53730@lists.php.net to get a copy of this message
On Sun, 03 Jul 2011 02:07:48 +0100, Jérôme Loyet <jerome@loyet..net> wrote:
the warnings appear in sapis (cgi, fpm, ...) and extensions (standard, ...) and the problem comes from the XOffsetOf macro which is expanded to offsetof defined in Zend/zend_operators.h whit the following code added in revisions 311662 and 312264: #ifndef offsetof #define offsetof(t,f) \ ((int)(&((t*)0)->f)) #endif
Yes, the cast should be changed to (size_t)(uintptr_t). I have also hit this problem a month ago. At the time I think I commented on IRC using (int)(intptr_t) instead could avoid problems like in "if (offsetof(x) - 5 < 0)", but since the C standard calls for a «expand[ing] to an integer constant expression that has type size_t», (size_t)(uintptr_t) seems preferable. -- Gustavo Lopes

« previous php.internals (#53730) next »