* Pointer difference
@ 2021-12-26 10:12 Marc Nieper-Wißkirchen
0 siblings, 0 replies; only message in thread
From: Marc Nieper-Wißkirchen @ 2021-12-26 10:12 UTC (permalink / raw)
To: Marc Nieper-Wißkirchen via Jit
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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-26 10:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-26 10:12 Pointer difference Marc Nieper-Wißkirchen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).