Re: Tree-walker callbacks vs -Wdeprecated-non-prototype
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-09-18T22:16:24Z
Lists: pgsql-hackers
On Mon, Sep 19, 2022 at 8:57 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > I think we ought to seriously consider the alternative of changing > nodeFuncs.c about like I have here, but not touching the walkers/mutators, > and silencing the resulting complaints about function type casting by > doing the equivalent of > > - return expression_tree_walker(node, cost_qual_eval_walker, > - (void *) context); > + return expression_tree_walker(node, > + (tree_walker_callback) cost_qual_eval_walker, > + (void *) context); > > We could avoid touching all the call sites by turning > expression_tree_walker and friends into macro wrappers that incorporate > these casts. 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 > BTW, I was distressed to discover that someone decided they could > use ExecShutdownNode as a planstate_tree_walker() walker even though > its argument list is not even the right length. I'm a bit flabbergasted > that we seem to have gotten away with that so far, because I'd have > thought for sure that it'd break some platform's convention for which > argument gets passed where. I think we need to fix that, independently > of what we do about the larger scope of these problems. To avoid an > API break, I propose making ExecShutdownNode just be a one-liner that > calls an internal ExecShutdownNode_walker() function. (I've not done > it that way in the attached, though.) Huh... wouldn't systems that pass arguments right-to-left on the stack receive NULL for node? That'd include the SysV i386 convention used on Linux, *BSD etc. But that can't be right or we'd know about it... But certainly +1 for fixing that regardless.
Commits
-
Remove accidentally added meson.build
- e7480f3dd6c2 13.22 landed
-
Disable clang 16's -Wcast-function-type-strict.
- 27831127d641 14.13 landed
- 6e2552d180a0 15.8 landed
- 101c37cd342a 16.0 landed
-
Disable -Wdeprecated-non-prototype in the back branches.
- 8c8ee5c99144 9.3 (unreleased) landed
- 5d3ce0d823c8 9.2 (unreleased) landed
- f9a56e726334 15.0 landed
- dcd7dbed5008 14.6 landed
- ca8fd341e165 9.6 (unreleased) landed
- 9afdf395042a 11.18 landed
- 7d5d3f05bfab 9.4 (unreleased) landed
- 52a5fd5b9f8f 12.13 landed
- 4c5a29c0e5e1 10.23 landed
- 43f72e0f73a5 13.9 landed
- 1b698659970e 9.5 (unreleased) landed
-
Revise tree-walk APIs to improve spec compliance & silence warnings.
- 1c27d16e6e5c 16.0 landed
-
Future-proof the recursion inside ExecShutdownNode().
- c35ba141de1f 16.0 landed
- cb7d636e0fb2 11.18 landed
- c58513f095e2 13.9 landed
- c403f97b4eab 15.0 landed
- adc26e0e88b3 12.13 landed
- 7394c763bc72 14.6 landed
- 68707e9c3f32 10.23 landed