[cc65] Optimizer bug found

From: Oliver Schmidt <ol.sc1web.de>
Date: 2009-09-10 23:19:34
Hi Uz,

After spending a "little" time I finally succeeded in isolating an
(maybe THE) optimizer bug causing Contiki to fail.

From my user perspective it is very interesting that the bug shows up
with compiler option -O but does _not_ show up with -Oi.

@Groepaz: Maybe your tests should be repeated with different optimizer
settings...

Here's the source:

====================

#include <stdio.h>

unsigned htons(unsigned val)
{
  return (((unsigned) (val)) << 8) | (((unsigned) (val)) >> 8);
}

void main(void)
{
  printf("%x -> %x\n", 0x1234, htons(0x1234));
}

====================

With 2.12.9.20090910-1 using -O the output is

1234 -> 1212

instead of the expected

1234 -> 3412

Have fun ;-)

Best, Oliver
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu, 10 Sep 2009 23:19:34 +0200

This archive was generated by hypermail 2.1.8 : 2009-09-10 23:19:44 CEST