Discussion:
[9fans] why does this compile?
(too old to reply)
erik quanstrom
2013-02-14 21:15:25 UTC
Permalink
this is rejected by most other compilers because
rlogn is not initialized to a constant. the value
returned is bizarre.

- erik
#include <u.h>
#include <libc.h>
static char rlog[24];
static char *rloge = rlog + sizeof rlog;
static char *rlogl = rlog + sizeof rlog - 1;
static char *rlogn = rloge - 1;
void
main(int, char **)
{
print("%p %p %p %p\n", rlog, rlogl, rlogn, rloge);
exits(nil);
}
Charles Forsyth
2013-02-14 21:22:25 UTC
Permalink
Post by erik quanstrom
the value
returned is bizarre.
it's the (lvalue of rloge)-1, not bizarre.
erik quanstrom
2013-02-14 21:26:15 UTC
Permalink
Post by Charles Forsyth
Post by erik quanstrom
the value
returned is bizarre.
it's the (lvalue of rloge)-1, not bizarre.
is that a legal thing to do?

- erik
erik quanstrom
2013-02-14 21:52:29 UTC
Permalink
No, but the value at least isn't bizarre. It would be correct for rloge as
an array, and i assume it gets through because of the way the
array->pointer change is done. Even so, if it had been GCC, by now it would
be an essential extension, and have been used to implement an elisp
interpreter, shave micro cycles from the time of a Java vm , and by GCC
itself. I might look at nipping all that in the bud tomorrow, although I
think I have looked at this once before.
thanks.

- erik
Charles Forsyth
2013-02-14 21:48:30 UTC
Permalink
No, but the value at least isn't bizarre. It would be correct for rloge as
an array, and i assume it gets through because of the way the
array->pointer change is done. Even so, if it had been GCC, by now it would
be an essential extension, and have been used to implement an elisp
interpreter, shave micro cycles from the time of a Java vm , and by GCC
itself. I might look at nipping all that in the bud tomorrow, although I
think I have looked at this once before.
Post by erik quanstrom
Post by Charles Forsyth
Post by erik quanstrom
the value
returned is bizarre.
it's the (lvalue of rloge)-1, not bizarre.
is that a legal thing to do?
- erik
Loading...