hydrogen-cpp icon indicating copy to clipboard operation
hydrogen-cpp copied to clipboard

Exit Exits twice

Open ApplePieCodes opened this issue 1 year ago • 4 comments

the code exit(12) produces the following ASM global _start _start: ;; exit mov rax, 12 push rax mov rax, 60 pop rdi syscall ;; /exit mov rax, 60 mov rdi, 0 syscall

the program exits twice.

ApplePieCodes avatar Sep 05 '24 11:09 ApplePieCodes

I believe he's intentionally adding an exit at the end of a program (even if you didnt add it yourself), which would mean that this isn't a bug (and you can't really exit twice, it exists and the second one isnt executed)

andriemc avatar Sep 30 '24 08:09 andriemc

I believe he's intentionally adding an exit at the end of a program (even if you didnt add it yourself), which would mean that this isn't a bug (and you can't really exit twice, it exists and the second one isnt executed)

This seems to be the case (check Line 247 of generation.hpp)

andriemc avatar Sep 30 '24 08:09 andriemc

Ok. I would change it to only add an exit if there is no exit declared in the program

ApplePieCodes avatar Sep 30 '24 10:09 ApplePieCodes

Ok. I would change it to only add an exit if there is no exit declared in the program

Personally I'd just leave it as is.

andriemc avatar Sep 30 '24 18:09 andriemc