waywardgeek / datadraw

Other
40 stars 10 forks source link

performing pointer subtraction with a null pointer has undefined behavior #3

Open nouraellm opened 1 year ago

nouraellm commented 1 year ago

I am actually trying to run this on macOS M1 (to use Rune) clang 14 => but the make throws a bunch of warnings like:

./utdatabase.h:157:70: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
utInlineC uint32 utSym2ValidIndex(utSym Sym) {return utValidSym(Sym) - (utSym)0;}

It is an undefined behavior because when a null pointer is involved in pointer subtraction we are violating C standards, so it is crucial to refrain from conducting pointer arithmetic with null pointers.