public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Antoni Boucher <bouanto@zoho.com>,
	"jit@gcc.gnu.org" <jit@gcc.gnu.org>,
	 "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] libgccjit: Allow sending a const pointer as argument
Date: Wed, 20 Nov 2024 10:54:17 -0500	[thread overview]
Message-ID: <59bba8edc19d1dc720e2a130b871256013bd57b0.camel@redhat.com> (raw)
In-Reply-To: <a5e30c7a9f9d27a2ef19d1f7ee5335aa14c7860e.camel@zoho.com>

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


      parent reply	other threads:[~2024-11-20 15:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21 16:59 Antoni Boucher
2024-01-19 20:59 ` Antoni Boucher
2024-02-17 16:55   ` Antoni Boucher
2024-10-15 17:09     ` Antoni Boucher
2024-11-20 15:54 ` David Malcolm [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=59bba8edc19d1dc720e2a130b871256013bd57b0.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=bouanto@zoho.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jit@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).