www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - typdefed pointer weirdness...

reply "noggin" <who not.me> writes:
not sure if this is a bug or not...

void test()
    {

    typedef int* pint;

    pint x;
    x =  x + 1; // error incompatible types 'pint' and 'int'
    x++; // ok

    int* y;
    y = y + 1; // ok
    y+; // ok

    }
Jun 08 2004
parent "Matthew" <matthew.hat stlsoft.dot.org> writes:
I suspect you want to be using alias.

If you do indeed mean typedef, then I have to say I'm not sure what the intended
behaviour should be. Since pint is a strong typedef, it's certainly the case
that
1 is not one of its type. Conversely, since pint is a pointer type, then we'd
expect to be able to do integer arithmetic.

I think you've found a little gremlin in the typedef type system, and it clearly
warrants some attention. My vote would be for allowing integer arithmetic on
strong pointer typedefs ... I think. :-)

"noggin" <who not.me> wrote in message news:ca5mlt$dda$1 digitaldaemon.com...
 not sure if this is a bug or not...

 void test()
     {

     typedef int* pint;

     pint x;
     x =  x + 1; // error incompatible types 'pint' and 'int'
     x++; // ok

     int* y;
     y = y + 1; // ok
     y+; // ok

     }
Jun 10 2004