GCC 17 Kills Trampolines: Nested Functions with Capture Now Trampoline-Free
Using GCC's Nested Functions with Wide Pointers and No Trampolines II
GCC 16 guarantees that nested functions not capturing parent variables avoid trampolines, and GCC 17 adds built-ins to eliminate trampolines even for capturing functions. This enables safe, efficient nested function calls with wide pointers, as demonstrated by a simple example that compiles to a single instruction.
In fact, with trampolines out of the picture, all that GCC does under the hood is to automatically transform this into the example above!