I am laughing and very interested. This is the first program IT created, that would compile.
main;
These are the warnings, but no errors!
Warning detected HelloWorld.c:1: warning: data definition has no type or storage class Warning detected HelloWorld.c:1: warning: type defaults to ‘int’ in declaration of ‘main’ Warning detected HelloWorld.c:1: warning: ‘main’ is usually a function
It determined the program was valid based on return from gcc (Only warns).
Compile successful.
What happened when it ran.
Segmentation fault
I arranged the program so it would read words and symbols from a file and then choose an order and amount at random to use them to write a file and then compile. If it had no errors, it would execute the compiled program and speak it. I find it very interesting in concept, that it creates things that I would never dream of doing and exposes some very interesting responses from gcc, the system, and nodes of function which I could never dream existed. The fact that "main;" is a complete program that can compile without error is wild. The best I could do on my own was "main(){}".
My next step is to always link it with the sighandler so it knows when it has failed and pipe the output to the main program for analysis of failures or effectiveness for a specific purpose. It took about 30 tries for it to come up with this program and I am really impressed, but who or what am I impressed with? IDK
I ran it again with new elements tab and space and it actually generated "main(){}", compiled with warns and ran to completion! That is spooky. In about 50 iterations, it has learned to make a program that compiles and runs! VERY ODD.
I had an odd thought which was scary, it could come up with a program that was "main(){system("rm -rf /")}" and that is just too scary. I need to run the programs on a separate machine across the network, and that may not even be enough isolation if it advances enough. I am sure it would use the internet to get examples and then what? I need to have a monitor that checks the programs it runs to see if they are safe. I can see that this is a large complex of operations that will have to operate in concert. This new program is dubbed "AMOEBA INSTRUCTOR(AI)". I see that "ACTION INVESTIGATOR(AI)" will have to exist too. So, "ALICE INFINITY(AI)", you have new friends to talk to.
Here is a program it came up with that failed: :)
ireturn jif0#endif#includecase#ifdefreturnforstruct
Here is another that compiled and I would never in my dreams suspect that this would compile with just warns!
* main; int;
This is the response of gcc to the code above. I think this program could win the obfuscated C award if it keeps this up.
Warning detected HelloWorld.c:1: warning: data definition has no type or storage class Warning detected HelloWorld.c:1: warning: type defaults to ‘int’ in declaration of ‘main’ Warning detected HelloWorld.c:1: warning: ‘main’ is usually a function Warning detected HelloWorld.c:2: warning: useless type name in empty declaration Compile successful.
Here is another and I wouldn't suspect this should compile without errors, and yet it does. This is very enlightening and I am losing the entertainment value and so I will push it up a notch and make it remember good and bad now to see if IT will become more amusing.
main;main ;; ;
Here is one more and this will be the last, as I am getting sick of posting them. You will have to try this yourself to see what it does and I assure you it has a wealth of entertainment value. I just can't believe "0;" is not an error at compile. I guess I never realized how many places a person could go wrong with the compile. I am used to assembly language and you are pretty much done for with a single comma in the wrong place or any stray element.
int main(){ 0;};
0 comments:
Post a Comment