Skip to content

avoid null-pointer-subtraction error#78

Merged
nitzmahone merged 1 commit intopython-cffi:mainfrom
nitzmahone:avoid_null_ptr_subtraction_warn
May 23, 2024
Merged

avoid null-pointer-subtraction error#78
nitzmahone merged 1 commit intopython-cffi:mainfrom
nitzmahone:avoid_null_ptr_subtraction_warn

Conversation

@nitzmahone
Copy link
Member

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.

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.
@nitzmahone nitzmahone mentioned this pull request May 23, 2024
5 tasks
@nitzmahone nitzmahone merged commit 39bdab2 into python-cffi:main May 23, 2024
@nekopsykose
Copy link

is there any reason to not make this offsetof(%s, %s) instead?

@arigo
Copy link
Contributor

arigo commented Jun 29, 2024

We can't in this case, because we have the name of the pointer type, and not the struct name type. See the next line after the else: for the case where we have the struct name and can just emit offsetof.

@nekopsykose
Copy link

that makes sense, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants