Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1958 Incorrect handling of arithemetic operations on void pointer

closed-invalid
nobody
Front-end
5
2015-03-09
2012-03-01
Anonymous
No

The following code compiles withou any warnings using SDCC : mcs51 3.1.0 #7066 (Nov 28 2011) (Mac OS X x86_64):

static void *ptr;
static unsigned char n;

void main(void)
{
ptr += n;
}

However, the generated code does nothing:

; testcase2.c:7: ptr += n;
ret

Discussion


  • Anonymous
    2012-03-01

    • summary: pointerIncorrect handling of arithemetic operations on void --> Incorrect handling of arithemetic operations on void pointer
     
    • assigned_to: nobody --> spth
    • status: open --> closed-invalid
     
  • Maybe we should warn here, since you seem to be at least the second person running into this and not liking what sdcc does. Nevetheless, AFAIK, this is standard-compliant bahaviour.

    Philipp

     
  • It seems I was partially wrong. While sdcc's current behaviour is correct for C89/90, C95 and C99, it is not for C11. We should make it an error for C11, which does not allow pointers to incomplete object types as addition operands.

    Philipp

     
    • assigned_to: spth --> nobody
    • status: closed-invalid --> open
     
  • Ben Shi
    Ben Shi
    2015-03-09

    • Category: --> Front-end
     
  • Ben Shi
    Ben Shi
    2015-03-09

    • status: open --> closed-invalid
     
  • Ben Shi
    Ben Shi
    2015-03-09

    I have tried above c code with all --std-c89, --std-c99, --std-sdcc89, --std-sdcc99, that all gave an error 66.