From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 62DDB3858C20 for ; Mon, 31 Jan 2022 14:49:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 62DDB3858C20 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-584-eD2JbpYYMz2HuaCt64Cu-g-1; Mon, 31 Jan 2022 09:49:03 -0500 X-MC-Unique: eD2JbpYYMz2HuaCt64Cu-g-1 Received: by mail-qv1-f72.google.com with SMTP id bx10-20020a056214058a00b00424e90c0dc4so12892483qvb.6 for ; Mon, 31 Jan 2022 06:49:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=w+zGvXK5Pbmkqc99kHumlPRL91qFszB1JBNZMPpvNzw=; b=T4Ngmoxl3dZKxqevPpCZT8jfRz6Zbr89fBd36zLg3RPkpJkQQTxzg6aSK0fDakp+Sf ztypUuowxjIrtCsGeDU/KtbqbU5WzR1ZCK0LPqEEbmIqNr0HXVRhk9miMeoDdvAZRSrV WaTsrLvB5lveJlQYIc/Vjw6qTs+j6uY2GVMWKJ73SE0c/ee7tFMW1gBoeLqQRuJgNod2 T9L35dltKBGVK78YcbgISqCO0AAPZOmC7UdjgSqGw0HwxE6ov/MYo0CVUoXuIgVYH2jr WiIwzwVoTDvKHoT4EQdNeUS5cOFyVMLOTwGz0GtUF+LUDxL7Q+YsFPsT/Dv0uLgFk8OZ 5fKQ== X-Gm-Message-State: AOAM531/JLMZa+DBwNVxQUixCNIo15UTGTvS0/BgP9tT4iMYls36Bnxu K5scdzp8L0Y31VW8HJpepfyq4JcjZ4s4b+3pyeR7eIpreoLY73oZeuqtMgheDvVDvxlRxZlUagU Eu/+P4Hc= X-Received: by 2002:ac8:59c6:: with SMTP id f6mr11652886qtf.343.1643640543232; Mon, 31 Jan 2022 06:49:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxih1tY5coAMqcg+28cOGsVKKRTHaF4mJ6QRDCP6Fp714ok6g+3wF0yGlaKpmhcWwiOUC/3fg== X-Received: by 2002:ac8:59c6:: with SMTP id f6mr11652870qtf.343.1643640542998; Mon, 31 Jan 2022 06:49:02 -0800 (PST) Received: from t14s.localdomain (c-73-69-212-193.hsd1.ma.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id j196sm8248896qke.134.2022.01.31.06.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 06:49:02 -0800 (PST) Message-ID: <1e83575c7d369fa96844b551f8606922fc8e0627.camel@redhat.com> Subject: Re: C++ API: Vector arguments / error detection From: David Malcolm To: Marc =?ISO-8859-1?Q?Nieper-Wi=DFkirchen?= , Marc =?ISO-8859-1?Q?Nieper-Wi=DFkirchen?= via Jit Date: Mon, 31 Jan 2022 09:49:01 -0500 In-Reply-To: References: User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: jit@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Jit mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Jan 2022 14:49:06 -0000 On Sun, 2022-01-30 at 16:35 +0100, Marc Nieper-Wißkirchen via Jit wrote: > This is about two unrelated issues regarding the C++ API: > > (1) At the moment, a lot of API functions like new_function take non- > const > referenced to vectors, e.g. std::vector ¶ms; > > Can we change this into const references?  This way, one can write > > auto param1 = ctxt.new_param (...); > auto param2 = ctxt.new_param (...); > auto func = new_function (..., {param1, param2}, ...); > > instead of the more complicated and less convenient > > auto param1 = ...; > auto param2 = ...; > auto params = std::vector {param1, param2}; > auto func = new_function (..., params, ...); I wonder why they're not const already - maybe I just forgot? Making the refs const sounds like a good idea to me. > > (2) When using gccjit::context::compile_to_file, how can I check > whether > the compilation succeeded without errors or not? In libgccjit++.h no > error > is checked and no exception thrown. Looks like I forgot to: (a) give a return value to gcc_jit_context_compile_to_file, and (b) add C++ bindings for gcc_jit_context_get_first_error and gcc_jit_context_get_last_error. Looks like fixing (a) would be an ABI break, bother (perhaps we could add a revised gcc_jit_context_compile_to_file symbol and do it with symbol versioning) With those in place, it looks like either the client code needs to check gcc::jit::context::get_last_error on failure, or, better, it should probably change to look something like this (untested): inline void context::compile_to_file (enum gcc_jit_output_kind output_kind, const char *output_path) { if (gcc_jit_context_compile_to_file (m_inner_ctxt, output_kind, output_path)) throw error (m_inner_ctxt); } where error's ctor should call gcc::jit::context::get_last_error on the ctxt, or something similar to this. Sorry about the C++ API being much less polished that the C API. Dave