Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oa8TV-0005nO-61 for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Sep 2022 04:33:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oa8TU-0003tZ-1p for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Sep 2022 04:33:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oa8TT-0003tQ-Mm for pgsql-hackers@lists.postgresql.org; Mon, 19 Sep 2022 04:33:39 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oa8TR-0008KO-8e for pgsql-hackers@postgresql.org; Mon, 19 Sep 2022 04:33:38 +0000 Received: by mail-ed1-x532.google.com with SMTP id z97so39513453ede.8 for ; Sun, 18 Sep 2022 21:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=TbTUr0yuo5ZVNK0FCluJ35Yf56BM21QPkW+VrRxv9rc=; b=lHit46qkVOzoaahjftwzSMRHozD3ZNm9PFEReetH3aIUGtzMBNW3iQ+sUtiJRZHlBZ u4+JmHp3KbcIGc9xXCzl5xGCocW6JC1kbj3n6x0Dq/A7PIGWOTvC37KbuNAnyBZG29D8 Q5XBmzshFvw9EQ1UDsYriJuO3D6+eagk4JcGyJN20U3nrP8RlPAykO8YNKpsnLjmrcee jCeZ9olfkeSmT0TgnqTVj9gskuSEJcklzzQY43twPoWSyixBjJo0fADVuxh7Od+5cYnj gnGAQQPMp/X2deT5nMAVhA5ma2jdpv3ElnO5byJ+pflUZ7chOiyHtGH29stYPCm2n89L YHlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=TbTUr0yuo5ZVNK0FCluJ35Yf56BM21QPkW+VrRxv9rc=; b=sCQYKwSoyjHFCeITSPKu5ln6SJ8j1Lvid42+K6mBmNL/b7u0cRBpgyUpu0PPc20MwI CN1CCWm5NVUZ4joSJ9RmPlcAvNYEeXGopdrlz7MVVZqVfy/em34zDdvXMR7JJeWHu6Z2 D2YZz0afmHTxBOMbTdGEsO6HTjR3drwnjcGv1ipbIObV38mj7aHHsNLzV/zmd6GeHHmd TbTImwKhhqAgQzEXjauz7v5soLdY7hjFThE90xO9++daBX4DbdIlSrnt0sMtQErWWNPf w9XpIUi3q6f+MrkFVDLMptIahWx+gwSEKPfe/qnK9weM9LJDdeLYYy1bseR/lX33hUJT 4sYA== X-Gm-Message-State: ACrzQf1I+9NHF3wHP4K5SEqTzaaE4+SEgjkNGnlklPfOrJZt+oY1Wenv GymXmYqULhoaWeT6llREm6FhWpzHu9n/Xotc/LM659K6g0NHxg== X-Google-Smtp-Source: AMsMyM6Vc5iRQ//+z78jO0t+Tf8+ht2tPbs6F9XPSJ7E0ZEbXAelJ1zpe/2br2TwLTaakfWmGo3npj5RInNBhSgzSlg= X-Received: by 2002:a50:ef03:0:b0:44e:82bf:28e6 with SMTP id m3-20020a50ef03000000b0044e82bf28e6mr13333874eds.270.1663562015704; Sun, 18 Sep 2022 21:33:35 -0700 (PDT) MIME-Version: 1.0 References: <1725174.1651449765@sss.pgh.pa.us> <3953550.1663376882@sss.pgh.pa.us> <208054.1663534665@sss.pgh.pa.us> <251836.1663558778@sss.pgh.pa.us> In-Reply-To: <251836.1663558778@sss.pgh.pa.us> From: Thomas Munro Date: Mon, 19 Sep 2022 16:32:59 +1200 Message-ID: Subject: Re: Tree-walker callbacks vs -Wdeprecated-non-prototype To: Tom Lane Cc: pgsql-hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Sep 19, 2022 at 3:39 PM Tom Lane wrote: > Thomas Munro writes: > > On Mon, Sep 19, 2022 at 8:57 AM Tom Lane wrote: > >> ... This is fairly annoying, in that it gives up the function > >> type safety the C committee wants to impose on us; but I really think > >> the data type safety that we're giving up in this version of the patch > >> is a worse hazard. > > > But is it defined behaviour? > > https://stackoverflow.com/questions/559581/casting-a-function-pointer-to-another-type > > Well, what we're talking about is substituting "void *" (which is > required to be compatible with "char *") for a struct pointer type. > Standards legalese aside, that could only be a problem if the platform > ABI handles "char *" differently from struct pointer types. The last > architecture I can remember dealing with where that might actually be > a thing was the PDP-10. Everybody has learned better since then, but > the C committee is apparently still intent on making the world safe > for crappy machine architectures. > > Also, if you want to argue that "void *" is not compatible with struct > pointer types, then it's not real clear to me that we aren't full of > other spec violations, because we sure do a lot of casting across that > (and even more with this patch as it stands). > > I don't have the slightest hesitation about saying that if there's > still an architecture out there that's like that, we won't support it. > I also note that our existing code in this area would break pretty > thoroughly on such a machine, so this isn't making it worse. Yeah, I don't expect it to be a practical problem on any real system (that is, I don't expect any real calling convention to transfer a struct T * argument in a different place than void *). I just wanted to mention that it's a new liberty. It's one thing to cast struct T * to void * and back before dereferencing, and another to cast a pointer to a function that takes struct T * to a pointer to a function that takes void * and call it. I considered proposing that myself when first reporting this problem, but fear of language lawyers put me off.