Pointer difference
Marc Nieper-Wißkirchen
marc.nieper+gnu@gmail.com
Sun Dec 26 10:12:37 GMT 2021
Using gcc_jit_context_new_binary_op together with
GCC_JIT_BINARY_OP_MINUS, one can generate code to calculate the
difference of two pointer rvalues P and Q.
According to my experiments, however, the difference is not taken in
the C sense where the difference is the number of units between the
two pointers, which depends on the types of P and Q. Instead,
libgccjit seems to calculate the equivalent of GCC's (void *) P -
(void *) Q.
It's probably worth noting this in the documentation.
Thanks,
Marc
PS Coincidentally, libgccjit doesn't support the addition of an
integral type to a pointer type using GCC_JIT_BINARY_OP_PLUS; for that
one has to go through gcc_jit_context_new_array_access and then
gcc_jit_lvalue_get_address.
More information about the Jit
mailing list