在 2025-5-14 16:26, Laurent Carlier via Gcc-help 写道:
I’m surprised that there is an assembly generation difference which seems related to TCO. I.E. there is a `call` instruction generated iso of a `jmp`
In this case it looks like that forcing `fd` to be stored in memory like printf("&fd = %p\n", (void*) &fd);will prevent a tail call. It doesn't matter where you put it, or whether the argument to `close()` is `fd` or not. I don't know a technical reason, however I did encounter such issues a few times ago.
OT: The operation to check for a valid FD is `fd >= 0`, rather than `fd > 0`. -- Best regards, LIU Hao
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature