Closed JaredCrean2 closed 2 years ago
Hi @JaredCrean2. Thanks for reporting this.
I have not used/seen null pointer subtraction before and need to look into this more. From my initial scan of some stack overflow comments it seems like it is used to check for type alignment.... I'm not sure how that applies here though.
It looks like clang 13 should also produce this warning: https://releases.llvm.org/13.0.0/tools/clang/docs/ReleaseNotes.html#new-compiler-flags
Looking at the code again:
https://github.com/SCOREC/core/blob/8a38feae942ab5a46dc3f9fa393a68884ddddad6/gmi/gmi_base.c#L39-L46
it appears that the purpose of the NULL subtraction is to recover an integer for the geometric model entity id. Simply casting produces a type size warning:
https://godbolt.org/z/EhGz1aMe5
edit: casting to an intptr_t
appears to work... https://godbolt.org/z/sdsjEPzr8
@JaredCrean2 Can you try building with the gmiNullPtr branch? If that works for you I'll merge this into develop
. Note, I tested with gcc 10.1.0 on a 64b system.
There are two commits to that branch:
intptr_t
and asserts that the results are the same as the char* p
NULL ptr subtraction pathchar*
and int
vars.Builds with no warnings or errors.
Thank you. The branch was merged into develop: https://github.com/SCOREC/core/commit/d1caa0b420bface29e2d111c4226b8099d2e628d .
Got this error:
with