Address of register variable requested

Advertisements

I am trying to simplify the following fragment of code:

void foo() {
    register int r0, r1, r2, r3;
    r0 = 0;
    r1 = 0;
    r2 = 0;
    r3 = 0;
}

by introducing constant-size array and a loop over it

void foo() {
    register int r[4];
    for (int i = 0; i < 4; i++) {
        r[i] = 0;
    }
}

What I noticed is that it is not supported by some versions of compilers. Why?

>Solution :

If the array object has register storage class, the
behavior is undefined.
.

Leave a ReplyCancel reply