Can This C Code Compile Under g++

J

Jack

The code at the bottom is obfuscated c and was a category winner of the
1989 IOCCC
http://www.ioccc.org/1989/roemer.c
Does anyone have a trick to make it compile under g++? Thanks.


char
_3141592654[3141
],__3141[3141];_314159[31415],_3141[31415];main(){register char*
_3_141,*_3_1415, *_3__1415; register int
_314,_31415,__31415,*_31,
_3_14159,__3_1415;*_3141592654=__31415=2,_3141592654[0][_3141592654
-1]=1[__3141]=5;__3_1415=1;do{_3_14159=_314=0,__31415++;for( _31415
=0;_31415<(3,14-4)*__31415;_31415++)_31415[_3141]=_314159[_31415]= -
1;_3141[*_314159=_3_14159]=_314;_3_141=_3141592654+__3_1415;_3_1415=
__3_1415 +__3141;for (_31415 = 3141-
__3_1415 ; _31415;_31415--
,_3_141 ++, _3_1415++){_314
+=_314<<2 ; _314<<=1;_314+=
*_3_1415;_31 =_314159+_314;
if(!(*_31+1) )* _31 =_314 /
__31415,_314 [_3141]=_314 %
__31415 ;* ( _3__1415=_3_141
)+= *_3_1415 = *_31;while(*
_3__1415 >= 31415/3141 ) *
_3__1415+= - 10,(*--_3__1415
)++;_314=_314 [_3141]; if ( !
_3_14159 && * _3_1415)_3_14159
=1,__3_1415 = 3141-_31415;}if(
_314+(__31415 >>1)>=__31415 )
while ( ++ * _3_141==3141/314
)*_3_141--=0 ;}while(_3_14159
) ; { char * __3_14= "3.1415";
write((3,1), (--*__3_14,__3_14
),(_3_14159 ++,++_3_14159))+
3.1415926; } for ( _31415 = 1;
_31415<3141- 1;_31415++)write(
31415% 314-( 3,14),_3141592654[
_31415 ] + "0123456789","314"
[ 3]+1)-_314; puts((*_3141592654=0
,_3141592654)) ;_314= *"3.141592";}
 
N

Nikos Chantziaras

Jack said:
The code at the bottom is obfuscated c and was a category winner of the
1989 IOCCC
http://www.ioccc.org/1989/roemer.c
Does anyone have a trick to make it compile under g++? Thanks.

g++? It's a C program. It compiles just fine in gcc (v3.4.4). It
doesn't run (segfault), but compiles. Is there a reason why you need to
compile it as C++ instead of C?
 
G

Greg

Victor said:
No, the code won't compile under current compilers. Too much non-
standard stuff in it.

V

gcc 4.0 will compile this source once the three or so stray space
characters that are splitting integer constants into two tokens are
removed. These spaces were were apparently inserted by the posting
software and are not part of the original C program.

Note that this is a C (not C++) program and should be saved to a file
with ".c" extension. The gcc compiler when compiling this code does
issue a few warnings about implicit int declarations, but these
warnings are not errors in C, apparently. Also I cannot get the built
program to run without crashing, so I may look further into the problem
there. These obfuscated C programs, though often difficult to tell what
they are doing from their source code (no kidding), were supposed to do
something useful when they did run.

Greg
 
J

Jerry Coffin

Greg wrote:

[ ... ]
These obfuscated C programs, though often difficult to tell what
they are doing from their source code (no kidding), were supposed to do
something useful when they did run.

In this case "useful" would be stretching it a bit -- all it does is
compute e (the base of natural logarithms) to some inordinate level of
precision.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top