After more debugging the issue reported in [83f953493d] seems to come from the many programs/functions (>200) defined in cobcjapi.cob (which is completely fine, we have no limit other than memory!) and a recursive call to codegen()
to resolve those, in combination with C optimization applied to cobc.
While this looks like a bug in GCC 6.3 (it doesn't happen any more with the MSYS2 builds which uses GCC 10) not in cobc it seems to be very reasonable to cleanup the main function for codegenerations and to remove the recursive call in theoretically infinite depth.
Commit: [r5268]
Discussion: 83f953493d
Discussion: Issues with MSYS GnuCOBOL Build
Refactoring done and at least he initial problem fixed with [r3738].