#1083 unsigned long *const w, xtea stream cypher

closed-fixed
5
2013-05-25
2006-03-26
No

Hi,
SDCC chokes on the ansi C xtea algorithm as provided
at:
http://www.simonshepherd.supanet.com/source.htm#new_ansi

void encipher(const unsigned long *const v,unsigned
long *const w,
const unsigned long * const k)
{
register unsigned long
y=v[0],z=v[1],sum=0,delta=0x9E3779B9,n=32;

while(n-->0)
{
y += (z << 4 ^ z >> 5) + z ^ sum + k[sum&3];
sum += delta;
z += (y << 4 ^ y >> 5) + y ^ sum + k[sum>>11 & 3];
}

w[0]=y; w[1]=z;
}

xtea.c:13: error 33: Attempt to assign value to a
constant variable (=)

Discussion

  • Frieder Ferlemann

    Logged In: YES
    user_id=589052

    This is a stripped down example which also exposes the bug:

    ------8<--------------------------------
    /* this gives an error (not OK).
    The keyword "const" seems to
    be attributed to the value pointed to
    instead of to the pointer itself
    */
    void should_not_give_error(char * const w)
    {
    w[0]='a';
    }

    /* (OK) */
    void does_not_give_error(char * w)
    {
    w[0]='a';
    }

    /* this gives an error (OK) */
    void gives_error(const char * w)
    {
    w[0]='a';
    }

     
  • Maarten Brock

    Maarten Brock - 2006-04-27

    Logged In: YES
    user_id=888171

    Bug 1302048 is related / the same.

     
  • Patryk

    Patryk - 2007-05-25

    Logged In: YES
    user_id=1788180
    Originator: NO

    This bug seems to be gone (or fixed) in SDCC 2.7.0 RC1 - tested for mcs51. It was present in 2.6.0.

     
  • Maarten Brock

    Maarten Brock - 2007-05-25

    Logged In: YES
    user_id=888171
    Originator: NO

    No it's not. I can easily reproduce it using the stripped down example.

     
  • Philipp Klaus Krause

    Logged In: YES
    user_id=564030
    Originator: NO

    This looks similar to #1717305.

    Philipp

     
  • Patryk

    Patryk - 2007-05-25

    Logged In: YES
    user_id=1788180
    Originator: NO

    maartenbrock - in fact! I tested some combinations with *(w+5) version, and it works (just checked that it worked also in 2.6.0). My fault, sorry for buzz :-(

     
  • Maarten Brock

    Maarten Brock - 2009-08-08

    This was caused by an incorrect fix for bug 1372851.
    Now fixed in SDCC 2.9.2 #5487.

     
  • Maarten Brock

    Maarten Brock - 2009-08-08
    • labels: --> C-Front End
    • milestone: --> fixed
    • assigned_to: nobody --> maartenbrock
    • status: open --> closed-fixed
     

Log in to post a comment.