9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] cc nit?
@ 2012-06-30 21:25 erik quanstrom
  2012-06-30 21:33 ` Bakul Shah
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: erik quanstrom @ 2012-06-30 21:25 UTC (permalink / raw)
  To: 9fans

i haven't tracked down thie issue yet, but it appears that ?c
generate unparsable acid output

; cat > void.c
typedef	struct	PNOTIFY	PNOTIFY

struct PNOTIFY {
	void	emptiness;
};
<eot>; 8c -a void.c
void.c:1 not a function
void.c:5 syntax error, last name: emptiness
sizeofPNOTIFY = 0;
aggr PNOTIFY
{
	T16
};

defn
PNOTIFY(addr) {
	complex PNOTIFY addr;
	T16
};



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

* Re: [9fans] cc nit?
  2012-06-30 21:25 [9fans] cc nit? erik quanstrom
@ 2012-06-30 21:33 ` Bakul Shah
  2012-06-30 21:37   ` erik quanstrom
  2012-07-01 16:54 ` Comeau At9Fans
       [not found] ` <CAE9W7-gZsWHuspmwBw0qU_djkiDhAF6hA2zLU3Ms=xiO1j5LXQ@mail.gmail.c>
  2 siblings, 1 reply; 17+ messages in thread
From: Bakul Shah @ 2012-06-30 21:33 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Sat, 30 Jun 2012 17:25:21 EDT erik quanstrom <quanstro@quanstro.net>  wrote:
> i haven't tracked down thie issue yet, but it appears that ?c
> generate unparsable acid output
>
> ; cat > void.c
> typedef	struct	PNOTIFY	PNOTIFY
>
> struct PNOTIFY {
> 	void	emptiness;
> };    ^^^^

Why would you do that?



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

* Re: [9fans] cc nit?
  2012-06-30 21:33 ` Bakul Shah
@ 2012-06-30 21:37   ` erik quanstrom
  2012-06-30 22:15     ` Bakul Shah
  0 siblings, 1 reply; 17+ messages in thread
From: erik quanstrom @ 2012-06-30 21:37 UTC (permalink / raw)
  To: 9fans

On Sat Jun 30 17:34:47 EDT 2012, bakul@bitblocks.com wrote:
> On Sat, 30 Jun 2012 17:25:21 EDT erik quanstrom <quanstro@quanstro.net>  wrote:
> > i haven't tracked down thie issue yet, but it appears that ?c
> > generate unparsable acid output
> >
> > ; cat > void.c
> > typedef	struct	PNOTIFY	PNOTIFY
> >
> > struct PNOTIFY {
> > 	void	emptiness;
> > };    ^^^^
>
> Why would you do that?

because there's nothing that needs to be saved there for the k10
architecture.

- erik



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

* Re: [9fans] cc nit?
  2012-06-30 21:37   ` erik quanstrom
@ 2012-06-30 22:15     ` Bakul Shah
  2012-07-01 13:47       ` erik quanstrom
  0 siblings, 1 reply; 17+ messages in thread
From: Bakul Shah @ 2012-06-30 22:15 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Sat, 30 Jun 2012 17:37:37 EDT erik quanstrom <quanstro@quanstro.net>  wrote:
> On Sat Jun 30 17:34:47 EDT 2012, bakul@bitblocks.com wrote:
> > On Sat, 30 Jun 2012 17:25:21 EDT erik quanstrom <quanstro@quanstro.net>  wr
> ote:
> > > i haven't tracked down thie issue yet, but it appears that ?c
> > > generate unparsable acid output
> > >
> > > ; cat > void.c
> > > typedef	struct	PNOTIFY	PNOTIFY
> > >
> > > struct PNOTIFY {
> > > 	void	emptiness;
> > > };    ^^^^
> >
> > Why would you do that?
>
> because there's nothing that needs to be saved there for the k10
> architecture.

I think this void exension is just plain broken. Try

#include <u.h>
#include <libc.h>
void foo; void bar;
main() { print("%p, %p\n", &foo, &bar);

It fails in the link stage for me.

I would've tried

    struct PNOTIFY {
	char	nothingness[0];
    };

as it more directly expresses the intent (at least to me) but
that doesn't work either.



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

* Re: [9fans] cc nit?
  2012-06-30 22:15     ` Bakul Shah
@ 2012-07-01 13:47       ` erik quanstrom
  0 siblings, 0 replies; 17+ messages in thread
From: erik quanstrom @ 2012-07-01 13:47 UTC (permalink / raw)
  To: 9fans

it's fixable with the following strategy
1.  cc: for void's, don't emit anything from the compiler's acid generator
2.  acid: accept empty aggrs.

i haven't pushed it to see if i can get acid to crash, and i don't have time
to right now, but this does improve the situation.

- erik

; diff -c /n/dump/2012/0701/sys/src/cmd/acid/dbg.y /sys/src/cmd/acid/dbg.y
/n/dump/2012/0701/sys/src/cmd/acid/dbg.y:75,82 - /sys/src/cmd/acid/dbg.y:75,85
  zsemi		:
  		| ';' zsemi

- members		: member
- 		| members member
+ members		:
+ 		{
+ 			$$ = nil;
+ 		}
+ 		| member members
  		{
  			$$ = an(OLIST, $1, $2);
  		}
; diff -c `{yesterday -n2 /sys/src/cmd/cc/acid.c} /sys/src/cmd/cc/acid.c
/n/dump/2012/0629/sys/src/cmd/cc/acid.c:112,117 - /sys/src/cmd/cc/acid.c:112,120
  		Bprint(&outbuf, "	T%d\n", t->etype);
  		break;

+ 	case TVOID:
+ 		break;		/* relies on acid being able to handle empty aggrs. */
+
  	case TIND:
  		if(s == S)
  			break;



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

* Re: [9fans] cc nit?
  2012-06-30 21:25 [9fans] cc nit? erik quanstrom
  2012-06-30 21:33 ` Bakul Shah
@ 2012-07-01 16:54 ` Comeau At9Fans
  2012-07-01 20:39   ` Charles Forsyth
       [not found] ` <CAE9W7-gZsWHuspmwBw0qU_djkiDhAF6hA2zLU3Ms=xiO1j5LXQ@mail.gmail.c>
  2 siblings, 1 reply; 17+ messages in thread
From: Comeau At9Fans @ 2012-07-01 16:54 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

On Sat, Jun 30, 2012 at 5:25 PM, erik quanstrom <quanstro@quanstro.net>wrote:

> i haven't tracked down thie issue yet, but it appears that ?c
> generate unparsable acid output
>
> ; cat > void.c
> typedef struct  PNOTIFY PNOTIFY
>
> struct PNOTIFY {
>         void    emptiness;
> };
> <eot>; 8c -a void.c
> void.c:1 not a function
> void.c:5 syntax error, last name: emptiness
> ...



I'm not sure where this is documented, but, isn't the problem (not just
syntactically) with the above the missing semicolon on the typedef line and
not the void'ness issue?

--
Greg Comeau / 4.3.10.1 with C++0xisms now in beta!
Comeau C/C++ ONLINE ==>     http://www.comeaucomputing.com/tryitout
World Class Compilers:  Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?

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

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

* Re: [9fans] cc nit?
       [not found] ` <CAE9W7-gZsWHuspmwBw0qU_djkiDhAF6hA2zLU3Ms=xiO1j5LXQ@mail.gmail.c>
@ 2012-07-01 16:57   ` erik quanstrom
  0 siblings, 0 replies; 17+ messages in thread
From: erik quanstrom @ 2012-07-01 16:57 UTC (permalink / raw)
  To: comeauat9fans, 9fans

> On Sat, Jun 30, 2012 at 5:25 PM, erik quanstrom <quanstro@quanstro.net>wrote:
>
> > i haven't tracked down thie issue yet, but it appears that ?c
> > generate unparsable acid output
> >
> > ; cat > void.c
> > typedef struct  PNOTIFY PNOTIFY
> >
> > struct PNOTIFY {
> >         void    emptiness;
> > };
> > <eot>; 8c -a void.c
> > void.c:1 not a function
> > void.c:5 syntax error, last name: emptiness
> > ...
>
>
>
> I'm not sure where this is documented, but, isn't the problem (not just
> syntactically) with the above the missing semicolon on the typedef line and
> not the void'ness issue?

that's true, i did miss the semicolon.  but that was a copypasta problem;
the issue still exists.

- erik



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

* Re: [9fans] cc nit?
  2012-07-01 16:54 ` Comeau At9Fans
@ 2012-07-01 20:39   ` Charles Forsyth
  2012-07-01 22:22     ` Comeau At9Fans
       [not found]     ` <CAE9W7-iFxd6ysP4cxRcGVuLT0n+SY2r4XjOTVpjpXi292v4WWQ@mail.gmail.c>
  0 siblings, 2 replies; 17+ messages in thread
From: Charles Forsyth @ 2012-07-01 20:39 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

instead of trying to make void work as a data type declaration, it might be
clearer to accept an empty struct.

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

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

* Re: [9fans] cc nit?
  2012-07-01 20:39   ` Charles Forsyth
@ 2012-07-01 22:22     ` Comeau At9Fans
  2012-07-01 22:32       ` Charles Forsyth
       [not found]     ` <CAE9W7-iFxd6ysP4cxRcGVuLT0n+SY2r4XjOTVpjpXi292v4WWQ@mail.gmail.c>
  1 sibling, 1 reply; 17+ messages in thread
From: Comeau At9Fans @ 2012-07-01 22:22 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

On Sun, Jul 1, 2012 at 4:39 PM, Charles Forsyth
<charles.forsyth@gmail.com>wrote:

> instead of trying to make void work as a data type declaration, it might
> be clearer to accept an empty struct.


Many compilers do just that, however, that said, unless the compiler is
prepared for it, since it effectively yields a struct of zero size which
normally is a no-go, it could produce bugs involving sizeof, initializers,
pointer addition et al, even some divisions by zero if the compiler is
making certain assumptions already, unless it already can have zero length
objects of this nature for some other reasons.

--
Greg Comeau / 4.3.10.1 with C++0xisms now in beta!
Comeau C/C++ ONLINE ==>     http://www.comeaucomputing.com/tryitout
World Class Compilers:  Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?

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

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

* Re: [9fans] cc nit?
  2012-07-01 22:22     ` Comeau At9Fans
@ 2012-07-01 22:32       ` Charles Forsyth
  2012-07-01 22:34         ` Charles Forsyth
  2012-07-02  0:18         ` Comeau At9Fans
  0 siblings, 2 replies; 17+ messages in thread
From: Charles Forsyth @ 2012-07-01 22:32 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

Yes, I was assuming the same approach as for the existing void data
declaration, that the structure is given a nominal size,
for just the reasons you give.  (That's what gcc seems to do.)

On 1 July 2012 23:22, Comeau At9Fans <comeauat9fans@gmail.com> wrote:

> Many compilers do just that, however, that said, unless the compiler is
> prepared for it, since it effectively yields a struct of zero size which
> normally is a no-go, it could produce bugs involving sizeof, initializers,
> pointer addition et al, even some divisions by zero if the compiler is
> making certain assumptions already, unless it already can have zero length
> objects of this nature for some other reasons.

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

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

* Re: [9fans] cc nit?
  2012-07-01 22:32       ` Charles Forsyth
@ 2012-07-01 22:34         ` Charles Forsyth
  2012-07-02  0:21           ` Comeau At9Fans
  2012-07-02  0:18         ` Comeau At9Fans
  1 sibling, 1 reply; 17+ messages in thread
From: Charles Forsyth @ 2012-07-01 22:34 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

Even better might be to do neither: eliminate support for void data, and
give the declaration a type that doesn't provoke so much discussion.
It's just a placeholder.

On 1 July 2012 23:32, Charles Forsyth <charles.forsyth@gmail.com> wrote:

> Yes, I was assuming the same approach as for the existing void data
> declaration, that the structure is given a nominal size,
> for just the reasons you give.  (That's what gcc seems to do.)
>

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

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

* Re: [9fans] cc nit?
       [not found]     ` <CAE9W7-iFxd6ysP4cxRcGVuLT0n+SY2r4XjOTVpjpXi292v4WWQ@mail.gmail.c>
@ 2012-07-01 22:45       ` erik quanstrom
  2012-07-02  0:24         ` Comeau At9Fans
  0 siblings, 1 reply; 17+ messages in thread
From: erik quanstrom @ 2012-07-01 22:45 UTC (permalink / raw)
  To: 9fans

> Many compilers do just that, however, that said, unless the compiler is
> prepared for it, since it effectively yields a struct of zero size which
> normally is a no-go, it could produce bugs involving sizeof, initializers,
> pointer addition et al, even some divisions by zero if the compiler is
> making certain assumptions already, unless it already can have zero length
> objects of this nature for some other reasons.

actually, kenc is pretty good about all these.  if you have

	struct fu {void x;};

and take sizeof(struct fu), that will give a diagnostic error.

the reason i avoided it was to not mess with the grammer, but if this is a
common thing, maybe it's no big deal.

though as charles points out, it is a bit of a waste of time.

- erik



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

* Re: [9fans] cc nit?
  2012-07-01 22:32       ` Charles Forsyth
  2012-07-01 22:34         ` Charles Forsyth
@ 2012-07-02  0:18         ` Comeau At9Fans
  2012-07-02  7:42           ` Charles Forsyth
  1 sibling, 1 reply; 17+ messages in thread
From: Comeau At9Fans @ 2012-07-02  0:18 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

On Sun, Jul 1, 2012 at 6:32 PM, Charles Forsyth
<charles.forsyth@gmail.com>wrote:

> Yes, I was assuming the same approach as for the existing void data
> declaration, that the structure is given a nominal size,
> for just the reasons you give.  (That's what gcc seems to do.)
>
> On 1 July 2012 23:22, Comeau At9Fans <comeauat9fans@gmail.com> wrote:
>
>> Many compilers do just that, however, that said, unless the compiler is
>> prepared for it, since it effectively yields a struct of zero size which
>> normally is a no-go, it could produce bugs involving sizeof, initializers,
>> pointer addition et al, even some divisions by zero if the compiler is
>> making certain assumptions already, unless it already can have zero length
>> objects of this nature for some other reasons.
>
>
Actually gcc gives it (the empty struct) sizeof zero (same as for its zero
length arrays).  Comeau mimics that behavior in gcc-mode, but used to/still
can also generate a dummy internal member too (usually a char bringing
forth sizeof 1).

--
Greg Comeau / 4.3.10.1 with C++0xisms now in beta!
Comeau C/C++ ONLINE ==>     http://www.comeaucomputing.com/tryitout
World Class Compilers:  Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?

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

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

* Re: [9fans] cc nit?
  2012-07-01 22:34         ` Charles Forsyth
@ 2012-07-02  0:21           ` Comeau At9Fans
  0 siblings, 0 replies; 17+ messages in thread
From: Comeau At9Fans @ 2012-07-02  0:21 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

On Sun, Jul 1, 2012 at 6:34 PM, Charles Forsyth
<charles.forsyth@gmail.com>wrote:

> Even better might be to do neither: eliminate support for void data, and
> give the declaration a type that doesn't provoke so much discussion.
> It's just a placeholder.
>
> On 1 July 2012 23:32, Charles Forsyth <charles.forsyth@gmail.com> wrote:
>
>> Yes, I was assuming the same approach as for the existing void data
>> declaration, that the structure is given a nominal size,
>> for just the reasons you give.  (That's what gcc seems to do.)
>>
>
I don't know where this will lead for 8c et al, so I'll throw it out there
anyway in the spirit of placeholders:

   int : 0;

--
Greg Comeau / 4.3.10.1 with C++0xisms now in beta!
Comeau C/C++ ONLINE ==>     http://www.comeaucomputing.com/tryitout
World Class Compilers:  Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?

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

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

* Re: [9fans] cc nit?
  2012-07-01 22:45       ` erik quanstrom
@ 2012-07-02  0:24         ` Comeau At9Fans
  0 siblings, 0 replies; 17+ messages in thread
From: Comeau At9Fans @ 2012-07-02  0:24 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

On Sun, Jul 1, 2012 at 6:45 PM, erik quanstrom <quanstro@quanstro.net>wrote:

> > Many compilers do just that, however, that said, unless the compiler is
> > prepared for it, since it effectively yields a struct of zero size which
> > normally is a no-go, it could produce bugs involving sizeof,
> initializers,
> > pointer addition et al, even some divisions by zero if the compiler is
> > making certain assumptions already, unless it already can have zero
> length
> > objects of this nature for some other reasons.
>
> actually, kenc is pretty good about all these.  if you have
>
>         struct fu {void x;};
>
> and take sizeof(struct fu), that will give a diagnostic error.
>
> the reason i avoided it was to not mess with the grammer, but if this is a
> common thing, maybe it's no big deal.
>
> though as charles points out, it is a bit of a waste of time.
>

If my memory serves, there is some wiggle room in C89 about how the empty
struct works, though generally it wouldn't fly, and C99 disallows it, while
C++ allows it (but it's sizeof > 0).  Plus it's a common extension made
prevalent via gcc.

--
Greg Comeau / 4.3.10.1 with C++0xisms now in beta!
Comeau C/C++ ONLINE ==>     http://www.comeaucomputing.com/tryitout
World Class Compilers:  Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?

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

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

* Re: [9fans] cc nit?
  2012-07-02  0:18         ` Comeau At9Fans
@ 2012-07-02  7:42           ` Charles Forsyth
  2012-07-02  7:45             ` Charles Forsyth
  0 siblings, 1 reply; 17+ messages in thread
From: Charles Forsyth @ 2012-07-02  7:42 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

You're right. I'd misread the assembly code.

On 2 July 2012 01:18, Comeau At9Fans <comeauat9fans@gmail.com> wrote:

> Actually gcc gives it (the empty struct) sizeof zero (same as for its zero
> length arrays).

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

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

* Re: [9fans] cc nit?
  2012-07-02  7:42           ` Charles Forsyth
@ 2012-07-02  7:45             ` Charles Forsyth
  0 siblings, 0 replies; 17+ messages in thread
From: Charles Forsyth @ 2012-07-02  7:45 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

Anyway, for a single use inside a single program, it's probably better just
to do what we'd do
if we couldn't just change the compiler, and change the type to a valid one
for data.

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

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

end of thread, other threads:[~2012-07-02  7:45 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-30 21:25 [9fans] cc nit? erik quanstrom
2012-06-30 21:33 ` Bakul Shah
2012-06-30 21:37   ` erik quanstrom
2012-06-30 22:15     ` Bakul Shah
2012-07-01 13:47       ` erik quanstrom
2012-07-01 16:54 ` Comeau At9Fans
2012-07-01 20:39   ` Charles Forsyth
2012-07-01 22:22     ` Comeau At9Fans
2012-07-01 22:32       ` Charles Forsyth
2012-07-01 22:34         ` Charles Forsyth
2012-07-02  0:21           ` Comeau At9Fans
2012-07-02  0:18         ` Comeau At9Fans
2012-07-02  7:42           ` Charles Forsyth
2012-07-02  7:45             ` Charles Forsyth
     [not found]     ` <CAE9W7-iFxd6ysP4cxRcGVuLT0n+SY2r4XjOTVpjpXi292v4WWQ@mail.gmail.c>
2012-07-01 22:45       ` erik quanstrom
2012-07-02  0:24         ` Comeau At9Fans
     [not found] ` <CAE9W7-gZsWHuspmwBw0qU_djkiDhAF6hA2zLU3Ms=xiO1j5LXQ@mail.gmail.c>
2012-07-01 16:57   ` 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).