Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various problems. #35

Open
rdebath opened this issue Dec 7, 2014 · 4 comments
Open

Various problems. #35

rdebath opened this issue Dec 7, 2014 · 4 comments

Comments

@rdebath
Copy link

rdebath commented Dec 7, 2014

I've just generated this piece of C code from a torture test of BF program interpreters. Obviously, being generated code it promises to be a bit of problem. I suspect this promise will be fulfilled.

https://gist.github.com/rdebath/ecd1454a259ece0a8ecf

The CPP define "C" can be declared, on the command line or inside, to be any integer type, signed or unsigned, for 8 bits to 128bits or more. The program, when run, should display one of a few variants of 'hello world' and then finish.

The default of integers complies and runs, but incorrectly.
Any type smaller then an integer gets a 'not an lvalue' error from a "-- * X" type construct.
Longs compile, but seem not to work at all, however, this appears to be a problem with 'stdint.h'.

Test run on Debian Wheezy.

@andrewchambers
Copy link
Contributor

Nothing in the code looks too crazy, though large parts of the code are being rewritten atm so the issue might need to wait until after the rewrite.

I'll make a smaller test case out of your code later though, it might be useful to fill holes in the 8cc test suite. I'll add it onto a branch on my own fork so I don't forget about it.

@rdebath
Copy link
Author

rdebath commented Dec 7, 2014

Heh, if you want crazy I can do that too ... https://gist.github.com/rdebath/2120d506bda710a76dd6

This one seems to work correctly, however, it doesn't get any constant folding done on it so the binary is a bit large (but the memory it needs to compile isn't too bad).

TODO: Constant folding of expressions like:

    x[4] += 1+1+1+1+1+1+1+1+1;
    si.flg = 4096+256+64+2+1;

@rui314
Copy link
Owner

rui314 commented Dec 8, 2014

This compiler has no serious test sets except the ones in test directory and the compiler itself. When I write new code for the compiler I sometimes found a miscompilation. So I wouldn't surprise that the code couldn't be compiled correctly with 8cc. I'll take a look later.

@andrewchambers
Copy link
Contributor

@rdebath I don't think we want crazy :). Sane code with errors is more useful. Also, 8cc doesn't do constant folding, it may need to in the future to fix issue #5 though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants