https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86259

Bernd Edlinger <bernd.edlinger at hotmail dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bernd.edlinger at hotmail dot 
de

--- Comment #26 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Hmmm, does this imply that
the "container_of" macro in linux/include/kernel.h will be broken:

/**
 * container_of - cast a member of a structure out to the containing structure
 * @ptr:        the pointer to the member.
 * @type:       the type of the container struct this is embedded in.
 * @member:     the name of the member within the struct.
 *
 */
#define container_of(ptr, type, member) ({                              \
        void *__mptr = (void *)(ptr);                                   \
        BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                         !__same_type(*(ptr), void),                    \
                         "pointer type mismatch in container_of()");    \
        ((type *)(__mptr - offsetof(type, member))); })


Or is the arithmetic on void * exempt from this undefined behavior?

Reply via email to