• Pointer subtract bug?

    From BartC@21:1/5 to All on Sun Oct 9 00:30:08 2016
    If I try to compile this with lccwin32:

    #include <stdint.h>

    int main(void) {
    unsigned char* p;
    unsigned char* q;
    int64_t value;

    p = q - value; // line 8

    }

    I get these errors:

    Error c.c: 8 operands of - have illegal types 'pointer to unsigned
    char' and 'long long'
    Error c.c: 8 operands of = have illegal types 'pointer to unsigned
    char' and 'int'

    Is there something wrong with the code, or is it a compiler bug?

    Version is:

    Logiciels/Informatique lcc-win32 version 3.8. Compilation date: Mar 29
    2013 13:11:27

    It seems to work OK with "+", but not "-".

    --
    Bartc

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From BartC@21:1/5 to BartC on Sun Oct 9 01:08:54 2016
    On 09/10/2016 00:30, BartC wrote:
    #include <stdint.h>

    int main(void) {
    unsigned char* p;
    unsigned char* q;
    int64_t value;

    p = q - value; // line 8

    }

    I get these errors:

    Error c.c: 8 operands of - have illegal types 'pointer to unsigned
    char' and 'long long'
    Error c.c: 8 operands of = have illegal types 'pointer to unsigned
    char' and 'int'

    Is there something wrong with the code, or is it a compiler bug?

    (BTW it's not urgent, as I use (int)value as a workaround.)

    --
    Bartc

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)