9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Skip Tavakkolian <skip.tavakkolian@gmail.com>
To: 9fans <9fans@9fans.net>
Subject: Re: [9fans] Strange 'uintptr' behavior
Date: Mon, 24 Jan 2022 14:26:34 -0800	[thread overview]
Message-ID: <CAJSxfmJfaDUEr6vSpneK5crQvRySMKMO1aurc1XrCC-ckYb75A@mail.gmail.com> (raw)
In-Reply-To: <CAGNd-2PeH=+_49O8eQSoCbOvExW8Nr8J9efcJVe9XMv8onHEcQ@mail.gmail.com>

maybe a previous fix was not applied?

there is a slight difference in the error messages
between the address of zeroth element vs first element
(see line 9 vs 10 errors below).  regardless, it's working
as expected on vanilla Plan 9:

% cat addrgames.c
#include <u.h>
#include <libc.h>

void
main(int argc, char **argv)
{
#ifdef USEUINTPTR
uintptr frst[] = {nil, nil, nil, nil, nil};
uintptr scnd[] = {nil, nil, frst, &frst[1]};
uintptr thrd[] = {nil, nil, frst, &frst[0]};
#else
void* frst[] = {nil, nil, nil, nil, nil};
void* scnd[] = {nil, nil, frst, &frst[1]};
void* thrd[] = {nil, nil, frst, &frst[0]};
#endif
exits("");
}
% 8c addrgames.c
% 5c addrgames.c
% vc addrgames.c
% 6c addrgames.c
% 5c -D USEUINTPTR addrgames.c
addrgames.c:8 incompatible types: "ULONG" and "IND VOID" for op "AS"
addrgames.c:8 incompatible types: "ULONG" and "IND VOID" for op "AS"
addrgames.c:8 incompatible types: "ULONG" and "IND VOID" for op "AS"
addrgames.c:8 incompatible types: "ULONG" and "IND VOID" for op "AS"
addrgames.c:8 incompatible types: "ULONG" and "IND VOID" for op "AS"
addrgames.c:9 incompatible types: "ULONG" and "IND VOID" for op "AS"
addrgames.c:9 incompatible types: "ULONG" and "IND VOID" for op "AS"
addrgames.c:9 incompatible types: "ULONG" and "IND ULONG" for op "AS"
addrgames.c:9 incompatible types: "ULONG" and "IND ULONG" for op "AS"
addrgames.c:10 incompatible types: "ULONG" and "IND VOID" for op "AS"
addrgames.c:10 incompatible types: "ULONG" and "IND VOID" for op "AS"
too many errors

On Mon, Jan 24, 2022 at 8:51 AM Pavel Klinkovský
<pavel.klinkovsky@gmail.com> wrote:
>
> Hi all,
>
> I tried some artificial example for Plan9 compiler (5c)...
>
> This code is compiled without any problem:
> uintptr frst[] = {nil, nil, nil, nil, nil};
> uintptr scnd[] = {nil, nil, frst, &frst[0]};
>
> But this one fails:
> uintptr frst[] = {nil, nil, nil, nil, nil};
> uintptr scnd[] = {nil, nil, frst, &frst[1]};
>
> ...with message:
> cpu% 5c -p t.c
> /usr/pavel/t.c:16[t.c:888] initializer is not a constant: scnd
>
> OTOH, replacement of 'uintptr' by 'void*' is compiled without any problem:
> void* frst[] = {nil, nil, nil, nil, nil};
> void* scnd[] = {nil, nil, frst, &frst[1]};
>
> Any explanation is appreciated.
>
> Pavel
>
> 9fans / 9fans / see discussions + participants + delivery options Permalink

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tb5fe0dc43447ab2c-M7fd1679cf965fc15eaceaa47
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

  parent reply	other threads:[~2022-01-24 22:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24 16:50 Pavel Klinkovský
2022-01-24 19:33 ` Alexandr Babic
2022-01-24 19:49   ` Pavel Klinkovský
2022-01-24 19:54     ` Alexandr Babic
2022-01-24 22:26 ` Skip Tavakkolian [this message]
2022-01-25  7:48   ` Pavel Klinkovský
2022-01-25  8:02     ` Re[2]: " Alexandr Babic
2022-01-25  8:26       ` Alex Musolino
2022-01-25  8:33         ` Pavel Klinkovský

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJSxfmJfaDUEr6vSpneK5crQvRySMKMO1aurc1XrCC-ckYb75A@mail.gmail.com \
    --to=skip.tavakkolian@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).