I couldn't get clang to, and gcc seems to be omitting the checks in some cases with your recursive call to foo (maybe it realizes that 'a' isn't actually accessed, but still emits the increase and decrease?). But gcc given a program that passes the address of 'a' into another function outside the compilation unit does emit stack probes with -fstack-check and -fstack-protector-all.
And I don't care if they didn't come out and say it in the spec. If your program depends on overflowing the stack into other regions of memory you need to be taken out into the street and publicly dealt with as an example to others. That being said, I'm sure there's something about implementation defined behavior around exceeding the platform's max for automatic storage duration objects. If not I may try to sneak that into C2X, lol.
https://godbolt.org/z/jHwZiG
And I don't care if they didn't come out and say it in the spec. If your program depends on overflowing the stack into other regions of memory you need to be taken out into the street and publicly dealt with as an example to others. That being said, I'm sure there's something about implementation defined behavior around exceeding the platform's max for automatic storage duration objects. If not I may try to sneak that into C2X, lol.