#892 no iCode created for pointer assignment

closed-invalid
nobody
5
2013-05-25
2005-03-09
No

The following snippet fails to create the correct
iCodes from AST nodes. Actually, no iCodes are
generated to perform the increasing of the c pointer.

#define SHOW_BUG 0

char reg(char *c)
{
#if SHOW_BUG
*(char **)c++; // <-- this doesn't increment
#else
*(char **)c+=1; // <-- this increments correct
#endif

return (c);
}

void main(void)
{
volatile char cc, bb;

bb = reg( &cc );
}

Tested with SDCC version 2.4.8 #967.
All ports fail.

regards,
Vangelis

Discussion

  • Raphael Neider

    Raphael Neider - 2005-03-09

    Logged In: YES
    user_id=1115835

    I don't think there's a bug here:

    Probably *(char **)c++ is to be read as *(char **)(c++) due
    to higher precedence of postfix-operators while you intended
    it to be understood as (*(char **)c)++, which is what the
    second expression does:
    *(char **)c += 1 is treated like (*(char **)c) += 1 due to
    lower precedence of += as compared to the cast.

    *(char **)c++ actually *does* increment c (in SDCC #968),
    the alternative ()-ed version from above also work.

    Greetings, Raphael

     
  • Raphael Neider

    Raphael Neider - 2005-07-22
    • milestone: --> non_bugs
    • status: open --> closed-invalid
     

Log in to post a comment.