Re:Show HN: A small virtual machine written in C
by akkartik on Monday August 04, 2014 @04:29AM
(#8130808)
In the process of debugging it I noticed that you're compiling but not linking in c99 mode. When I fix that the problem seems to go away:
Still, I'm concerned that you might be triggering some sort of undefined behavior, which means it might work for you but not on a slightly different machine or compiler version. I tried printing out token lexemes in carp_run_program, right after the call to tokenize(), and some of the tokens printed binary garbage, suggesting that they might be missing a terminating null, or worse. Does this look right?
The trouble with C/C++ is that it's so easy to end up with undefined behavior :/
[ Parent
| on HN ]
Re:Show HN: A small virtual machine written in C
by tekknolagi on Monday August 04, 2014 @04:36AM
(#8130837)
Actually I can't link with the same CFLAGS; I get an error about missing lcrt0.o or something of the sort.
Also, yeah your code looks fine; I added it in and it worked fine. That's unfortunate. I'll debug soon.
Re:Show HN: A small virtual machine written in C
by akkartik on Monday August 04, 2014 @04:46AM
(#8130854)
What machine/os are you on?
(Perhaps we should take this offline. My email is in my profile.)
Re:Show HN: A small virtual machine written in C
by tekknolagi on Monday August 04, 2014 @12:50PM
(#8132680)
Sent an email :)