Skip to content

Commit 39bdab2

Browse files
authored
avoid null-pointer-subtraction error (#78)
Newer compilers generate warnings/errors about null pointer subtractions being an undefined behavior. Use matching non-zero offsets (as suggested by arigo) to avoid the error.
1 parent d7f750b commit 39bdab2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cffi/recompiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ def _struct_ctx(self, tp, cname, approxname, named_ptr=None):
953953
if cname is None or fbitsize >= 0:
954954
offset = '(size_t)-1'
955955
elif named_ptr is not None:
956-
offset = '((char *)&((%s)0)->%s) - (char *)0' % (
956+
offset = '((char *)&((%s)4096)->%s) - (char *)4096' % (
957957
named_ptr.name, fldname)
958958
else:
959959
offset = 'offsetof(%s, %s)' % (tp.get_c_name(''), fldname)

0 commit comments

Comments
 (0)