9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] why does this compile?
@ 2013-02-14 21:15 erik quanstrom
  2013-02-14 21:22 ` Charles Forsyth
  0 siblings, 1 reply; 5+ messages in thread
From: erik quanstrom @ 2013-02-14 21:15 UTC (permalink / raw)
  To: 9fans

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);
> }



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] why does this compile?
  2013-02-14 21:15 [9fans] why does this compile? erik quanstrom
@ 2013-02-14 21:22 ` Charles Forsyth
  2013-02-14 21:26   ` erik quanstrom
  0 siblings, 1 reply; 5+ messages in thread
From: Charles Forsyth @ 2013-02-14 21:22 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 163 bytes --]

On 14 February 2013 21:15, erik quanstrom <quanstro@quanstro.net> wrote:

>  the value
> returned is bizarre.
>

it's the (lvalue of rloge)-1, not bizarre.

[-- Attachment #2: Type: text/html, Size: 514 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] why does this compile?
  2013-02-14 21:22 ` Charles Forsyth
@ 2013-02-14 21:26   ` erik quanstrom
  2013-02-14 21:48     ` Charles Forsyth
  0 siblings, 1 reply; 5+ messages in thread
From: erik quanstrom @ 2013-02-14 21:26 UTC (permalink / raw)
  To: 9fans

On Thu Feb 14 16:23:21 EST 2013, charles.forsyth@gmail.com wrote:

> On 14 February 2013 21:15, erik quanstrom <quanstro@quanstro.net> wrote:
>
> >  the value
> > returned is bizarre.
> >
>
> it's the (lvalue of rloge)-1, not bizarre.

is that a legal thing to do?

- erik



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] why does this compile?
  2013-02-14 21:26   ` erik quanstrom
@ 2013-02-14 21:48     ` Charles Forsyth
  2013-02-14 21:52       ` erik quanstrom
  0 siblings, 1 reply; 5+ messages in thread
From: Charles Forsyth @ 2013-02-14 21:48 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 862 bytes --]

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.
On 14 Feb 2013 21:27, "erik quanstrom" <quanstro@quanstro.net> wrote:

> On Thu Feb 14 16:23:21 EST 2013, charles.forsyth@gmail.com wrote:
>
> > On 14 February 2013 21:15, erik quanstrom <quanstro@quanstro.net> wrote:
> >
> > >  the value
> > > returned is bizarre.
> > >
> >
> > it's the (lvalue of rloge)-1, not bizarre.
>
> is that a legal thing to do?
>
> - erik
>
>

[-- Attachment #2: Type: text/html, Size: 1270 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] why does this compile?
  2013-02-14 21:48     ` Charles Forsyth
@ 2013-02-14 21:52       ` erik quanstrom
  0 siblings, 0 replies; 5+ messages in thread
From: erik quanstrom @ 2013-02-14 21:52 UTC (permalink / raw)
  To: 9fans

On Thu Feb 14 16:49:17 EST 2013, charles.forsyth@gmail.com wrote:

> 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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-02-14 21:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-14 21:15 [9fans] why does this compile? erik quanstrom
2013-02-14 21:22 ` Charles Forsyth
2013-02-14 21:26   ` erik quanstrom
2013-02-14 21:48     ` Charles Forsyth
2013-02-14 21:52       ` erik quanstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).