Do C compilers do tail calls through a pointer?
(How does that work if the target function has a separate entry point for accepting a tail call?)
If you pile up stack frames while matching regex, you will blow up on long matches. Eg. a+ matching string with thousands or millions of a's.
This could be made not to rely on tail call support by using a:
typedef struct cont {
void (*fn)(void *data);
void *data;
} cont_t;
which is returned from each function. A dispatch loop invokes the tail call by calling fn in the returned structure, passing it data. Needless to say, data can't be the address of some local variable in the function which returns this structure. Obviously, non-tail invocations of the continuations sometimes occur, and those have to be handled differently.