https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113904
--- Comment #7 from sandra at gcc dot gnu.org --- My most recent metadirectives/dynamic selector patch set does include partial support for dynamic selectors. For C/C++ it handles expressions that reference variables/functions that are globally visible, and for C++ also class fields/methods, references to the "this" pointer, etc, but it gives a "sorry" for references to parameters on the base function declaration. For Fortran it still permits only constant expressions in selectors. https://gcc.gnu.org/pipermail/gcc-patches/2024-May/650725.html I agree with Tobias's comment 3 that the right solution is to wrap these expressions in a function that has the same parameters as the associated base decl, and that these generated functions can be internal and inline. But, it might be more efficient to bypass actually creating functions and instead just stash a parameter map (e.g. to match parameter positions to decls) along with the expression so that the gimplifier can effectively do the inlining at the point where it synthesizes both the replacement call and the code to match dynamic selectors (in posted patch set above).