Announcement: Obfuscated Python competition
Graham Nicholls
graham at rockcons.co.uk
Mon May 19 15:28:39 EDT 2003
Jeff Epler wrote:
> On Mon, May 19, 2003 at 11:10:41AM -0600, Daniel Fackrell wrote:
>> ----
>> #include <stdio.h>
>> int main() {
>> int x;
>> x = 0;
>> x = ++x + ++x + x++ + x++; // This is legal C code, but what does it
>> do? printf("x is %d", x);
>> return 0;
>> }
>> ----
>> gcc under Cygwin/Linux: "x is 10"
>> cc on HPUX: "x is 8"
>> gcc under HP/UX: "x is 3"
>>
>> Just as a note, there were no warnings or errors while compiling.
>
> This is syntactically valid C code, but the standard specifically states
> that it produces undefined results.
>
> And, I should note, I *do* get compiler errors on this program:
> $ gcc -Wall -ansi -pedantic fackrell.c
> fackrell.c: In function `main':
> fackrell.c:5: warning: operation on `x' may be undefined
> fackrell.c:5: warning: operation on `x' may be undefined
> fackrell.c:5: warning: operation on `x' may be undefined
> fackrell.c:5: warning: operation on `x' may be undefined
> fackrell.c:5: parse error before '/' token
>
Quite.
> Jeff
I reckon its possible to write bad code in any language. So if it hasn't
been done already, how about an obfuscated Python competition.
Prize : One of my Perl books - lets see: "Perl in a Nuthouse" looks good.
BTW I reckon I'll have to keep up to date in both Perl & Python if I'm going
to make the switch - theres a _lot_ of perl out there. Some of it is
readable ( I reckon my own code to be readable, and take a pride in it
being so, but who knows...)
Graham
--
Graham Nicholls
All round good guy.
More information about the Python-list
mailing list