Skip to content

Commit

Permalink
libbase: fix definition of offsetof().
Browse files Browse the repository at this point in the history
Calculating an address of field based on an invalid pointer,
like NULL, is UB in C.
whitequark committed Sep 29, 2016
1 parent 6d46070 commit 806125b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion misoc/software/include/base/stddef.h
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ extern "C" {
typedef unsigned long size_t;
typedef long ptrdiff_t;

#define offsetof(s,m) (size_t)&(((s *)0)->m)
#define offsetof(type, member) __builtin_offsetof(type, member)

#ifdef __cplusplus
}

0 comments on commit 806125b

Please sign in to comment.