www.digitalmars.com         C & C++   DMDScript  

c++ - DMC++ mishandles perverse, but legal, revered subscripting syntax for arrays

reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
All compiles except where marked. All should compile

int main()
{
    char        c;
    char        *p  =   &c;
    unsigned    x   =   0;
    char        b[10];

    p[x] = 'o';
    x[p] = 'k';

    0[p] = 'r';

    b[x] = 'o';
    x[b] = 'k';     /* Compiler wrongly gives error */

    0[b] = 'r';     /* Compiler wrongly gives error */

    return 0;
}
Feb 19 2004
next sibling parent reply Ilya Minkov <minkov cs.tum.edu> writes:
Matthew wrote:
 All compiles except where marked. All should compile

i think it may better stay so. It's definately not very annoying since anyone sane wouldn't write that. You could just as well write (x+b) :> -eye
Feb 20 2004
parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
 Matthew wrote:
 All compiles except where marked. All should compile

i think it may better stay so. It's definately not very annoying since anyone sane wouldn't write that. You could just as well write (x+b) :>

Nonsense. It's non-standard behaviour, and in such a simple thing that any other compiler handles correctly. I really don't think you'll convince Walter to *not* do this, given his desire to be fully-conformant. And as for your assertion that no-one would use such a construct, I'll just smile, and you can wait until you've read "Imperfect C++". Now you've got three reasons to buy it (the other ones being the Properties chapter, and my mentioning your request for properties in the acknowledgements). :)
Feb 20 2004
parent reply Ilya Minkov <minkov cs.tum.edu> writes:
Matthew wrote:
Matthew wrote:

All compiles except where marked. All should compile

i think it may better stay so. It's definately not very annoying since anyone sane wouldn't write that. You could just as well write (x+b) :>

Nonsense. It's non-standard behaviour, and in such a simple thing that any other compiler handles correctly. I really don't think you'll convince Walter to *not* do this, given his desire to be fully-conformant.

It's probably so to guard for bugs.
 And as for your assertion that no-one would use such a construct, I'll just
 smile, and you can wait until you've read "Imperfect C++". Now you've got
 three reasons to buy it (the other ones being the Properties chapter, and my
 mentioning your request for properties in the acknowledgements).

I really don't need to count the reasons, i know i want to get it as soon as it's out. :> Unfortunately, /me would not be able to raise your sales much only by bying it myself. -eye
Feb 20 2004
parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
"Ilya Minkov" <minkov cs.tum.edu> wrote in message
news:c169kc$1fdf$2 digitaldaemon.com...
 Matthew wrote:
Matthew wrote:

All compiles except where marked. All should compile

i think it may better stay so. It's definately not very annoying since anyone sane wouldn't write that. You could just as well write (x+b) :>

Nonsense. It's non-standard behaviour, and in such a simple thing that


 other compiler handles correctly. I really don't think you'll convince
 Walter to *not* do this, given his desire to be fully-conformant.

It's probably so to guard for bugs.
 And as for your assertion that no-one would use such a construct, I'll


 smile, and you can wait until you've read "Imperfect C++". Now you've


 three reasons to buy it (the other ones being the Properties chapter,


 mentioning your request for properties in the acknowledgements).

I really don't need to count the reasons, i know i want to get it as soon as it's out. :> Unfortunately, /me would not be able to raise your sales much only by bying it myself.

Don't be so sure. You might account for up to 50% of sales! (I know my mum's going to buy one <g>)
Feb 20 2004
parent Ilya Minkov <minkov cs.tum.edu> writes:
Matthew wrote:
I really don't need to count the reasons, i know i want to get it as
soon as it's out. :> Unfortunately, /me would not be able to raise your
sales much only by bying it myself.

Don't be so sure. You might account for up to 50% of sales! (I know my mum's going to buy one <g>)

I've been spreading Word, so i'm sure i account for at most 34% of sales. -eye
Feb 21 2004
prev sibling parent reply "KTC" <me here.com> writes:
"Matthew" wrote...
 All compiles except where marked. All should compile

Have Walter fixed this already??? :-o Just tried it with 8.40 and it compiles fine... A very impress person, KTC -- Experience is a good school but the fees are high. - Heinrich Heine
Feb 21 2004
parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
He usually posts a response on the NG.

Did you try all the cases?

I just tried with 8.40.1, and it still fails.

"KTC" <me here.com> wrote in message news:c18pf7$30pl$1 digitaldaemon.com...
 "Matthew" wrote...
 All compiles except where marked. All should compile

Have Walter fixed this already??? :-o Just tried it with 8.40 and it compiles fine... A very impress person, KTC -- Experience is a good school but the fees are high. - Heinrich Heine

Feb 21 2004
parent reply "KTC" <me here.com> writes:
"Matthew" wrote...
 He usually posts a response on the NG.

 Did you try all the cases?

 I just tried with 8.40.1, and it still fails.

I've just copied and paste exactly what you posted in the orginial post and it compiles fine for me... scppn.exe gives version 8.40.2n KTC -- Experience is a good school but the fees are high. - Heinrich Heine
Feb 21 2004
parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
 "Matthew" wrote...
 He usually posts a response on the NG.

 Did you try all the cases?

 I just tried with 8.40.1, and it still fails.

I've just copied and paste exactly what you posted in the orginial post and it compiles fine for me... scppn.exe gives version 8.40.2n

That's what I have. I must conclude that I pasted an incomplete version. Including here again ... Walter, I presume this'll be easy-ish to fix. Any ETA? :)
Feb 21 2004
parent reply "KTC" <me here.com> writes:
"Matthew" wrote...
 That's what I have.

 I must conclude that I pasted an incomplete version. Including here

 ...

 Walter, I presume this'll be easy-ish to fix. Any ETA? :)

Ahha, discovered why. It compiles if one compiles it as C++ but not if it's C.
Feb 22 2004
parent "Matthew" <matthew.hat stlsoft.dot.org> writes:
"KTC" <me here.com> wrote in message news:c1a3um$2ivm$1 digitaldaemon.com...
 "Matthew" wrote...
 That's what I have.

 I must conclude that I pasted an incomplete version. Including here

 ...

 Walter, I presume this'll be easy-ish to fix. Any ETA? :)

Ahha, discovered why. It compiles if one compiles it as C++ but not if it's C.

That's interesting. It also explains a few things I was wondering about. :)
Feb 22 2004