On Thu, 2023-12-21 at 11:59 -0500, Antoni Boucher wrote:
> Hi.
> This patch adds the ability to send const pointer as argument to a
> function.
> Thanks for the review.

Sorry for the long delay in responding to this.

I'm a bit worried that this might break some type-safety within
libgccjit, or that you might have a bug in your client code.

In the testcase you have:

  gcc_jit_type *int_type =
    gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
  gcc_jit_type *int_ptr_type =
    gcc_jit_type_get_pointer (int_type);
  gcc_jit_type *const_ptr_type =
    gcc_jit_type_get_const (int_ptr_type);

  /* Build the test_ptr.  */
  gcc_jit_param *param =
    gcc_jit_context_new_param (ctxt, NULL, const_ptr_type, "value");

which is creating the equivalent of

  int *const value

i.e. a const pointer to a non-const int

whereas in the comment you have:

  /* Let's try to inject the equivalent of:

     int test_ptr(const int* value)

where "const int *" is a non-const pointer to a const int.

So is the get_const and the get_pointer the wrong way round somewhere
in your code?  Or am I missing something here?

Dave

Reply via email to