Discussion:
[9fans] C compiler error?
(too old to reply)
Lucio De Re
2011-12-13 12:42:23 UTC
Permalink
New features in Go require a new function in the reflect.c module
(src/cmd/gc/reflect.c). The C compiler (8c, in this case) reports an
error which does not seem to apply:

8c -I/go/include -I/go/386/include -FTVw ../gc/reflect.c
../gc/reflect.c:987 switch expression must be integer

This is a bit of a stumbling block. I'm hoping there's someone on
this mailing list that can address this problem quicker than it would
be possible for me. More details off line.

++L
erik quanstrom
2011-12-13 13:36:19 UTC
Permalink
Post by Lucio De Re
New features in Go require a new function in the reflect.c module
(src/cmd/gc/reflect.c). The C compiler (8c, in this case) reports an
8c -I/go/include -I/go/386/include -FTVw ../gc/reflect.c
../gc/reflect.c:987 switch expression must be integer
This is a bit of a stumbling block. I'm hoping there's someone on
this mailing list that can address this problem quicker than it would
be possible for me. More details off line.
i don't see 987 lines in reflect.c. from http://golang.org/src/cmd/gc/reflect.c,
i only see 939.

in any event, it's likely that your switch type is a uvlong. 8c doesn't allow
that.

- erik
Noah Evans
2011-12-13 13:52:03 UTC
Permalink
Erik, are you looking at the tip? IIRC the webpage points to a stable
version not the tip.

Noah
Post by Lucio De Re
New features in Go require a new function in the reflect.c module
(src/cmd/gc/reflect.c).  The C compiler (8c, in this case) reports an
8c -I/go/include -I/go/386/include -FTVw ../gc/reflect.c
../gc/reflect.c:987 switch expression must be integer
This is a bit of a stumbling block.  I'm hoping there's someone on
this mailing list that can address this problem quicker than it would
be possible for me.  More details off line.
i don't see 987 lines in reflect.c.  from http://golang.org/src/cmd/gc/reflect.c,
i only see 939.
in any event, it's likely that your switch type is a uvlong.  8c doesn't allow
that.
- erik
erik quanstrom
2011-12-13 13:55:59 UTC
Permalink
Post by Noah Evans
Erik, are you looking at the tip? IIRC the webpage points to a stable
version not the tip.
well too bad, no option to peek at the tip either.

in any event, i still bet you're switching on a uvlong.

- erik
yy
2011-12-13 14:07:40 UTC
Permalink
Post by erik quanstrom
Post by Noah Evans
Erik, are you looking at the tip? IIRC the webpage points to a stable
version not the tip.
well too bad, no option to peek at the tip either.
http://tip.golang.org/src/cmd/gc/reflect.c

(weekly.golang.org is there too)
--
- yiyus || JGL .
Charles Forsyth
2011-12-13 22:38:56 UTC
Permalink
it's reasonable to use any integer type in a switch, although the compilers
don't currently support it.
it's compatible with the standard, which allows any integer type. i'd
cancel the change request and work round it (add a cast) until
the compilers can be changed to support it.
Russ Cox
2011-12-13 23:01:43 UTC
Permalink
On Tue, Dec 13, 2011 at 5:38 PM, Charles Forsyth
Post by Charles Forsyth
it's reasonable to use any integer type in a switch, although the compilers
don't currently support it.
it's compatible with the standard, which allows any integer type. i'd cancel
the change request and work round it (add a cast) until
the compilers can be changed to support it.
http://codereview.appspot.com/5485063/ is a step toward it.
it doesn't generate the prettiest code but i think it works.

russ
Lucio De Re
2011-12-14 04:05:10 UTC
Permalink
Post by Russ Cox
On Tue, Dec 13, 2011 at 5:38 PM, Charles Forsyth
(add a cast) until
Post by Russ Cox
Post by Charles Forsyth
the compilers can be changed to support it.
http://codereview.appspot.com/5485063/ is a step toward it.
it doesn't generate the prettiest code but i think it works.
What is the expected status? Is Anthony's CL to be abandoned in
favour of the change to the Plan 9 C compiler (give or take the other
nit of a "static" definition)? I don't have a problem with minor
unofficial changes to the Plan 9 distribution, but others may object.

Lucio.
Lucio De Re
2011-12-14 04:08:25 UTC
Permalink
Was meant as private mail, sorry!

++L
Russ Cox
2011-12-14 04:19:29 UTC
Permalink
What is the expected status?  Is Anthony's CL to be abandoned in
favour of the change to the Plan 9 C compiler (give or take the other
nit of a "static" definition)?  I don't have a problem with minor
unofficial changes to the Plan 9 distribution, but others may object.
Since you sent this publicly, I will reply publicly.
We're not going to change the Go code to avoid
switches on 64-bit numbers, which are increasingly
common. I assume that Anthony will take care of
submitting the patch through the usual channels
and getting it applied.

Russ
Charles Forsyth
2011-12-14 09:20:26 UTC
Permalink
Is Anthony's CL to be abandoned in favour of the change to the Plan 9 C
compiler (give or take the other nit of a "static" definition)?

see my earlier remark:

"it's reasonable to use any integer type in a switch, although the
compilers don't currently support it.
it's compatible with the standard, which allows any integer type. *i'd
cancel the change request and work round it* (eg, add a cast) until
the compilers can be changed to support it."

Instead of making a small patch to the Go file locally, you could also
apply Russ's change locally to 8c, which might be easier.
That change will keep you going, but it doesn't look like a good one as it
stands to apply to the full compiler suite.
As my remark above suggests, the compiler suite should, however, support
using any integer type in a switch.
Anthony Martin
2011-12-14 10:10:09 UTC
Permalink
Charles Forsyth <***@gmail.com> once said:
I abandoned my old CL and sent another that
allows 64-bit switch expressions for all of
the Go compilers. A patch for [5678kqv]c
will be hitting sources soon. Stay tuned.

Anthony
Charles Forsyth
2011-12-14 10:34:57 UTC
Permalink
it would also help if I actually pushed the 64-bit changes for 5c, i
suppose.
how lucky i've recently got a machine to re-test them!
that's a little tidier, but still not right. the original pswt.c code was
fine (or nearly so). the problem is
actually in 8c's handling of 64-bit values and registers.
Charles Forsyth
2011-12-14 10:29:48 UTC
Permalink
that's a little tidier, but still not right. the original pswt.c code was
fine (or nearly so). the problem is
actually in 8c's handling of 64-bit values and registers.
Post by Anthony Martin
I abandoned my old CL and sent another that
allows 64-bit switch expressions for all of
the Go compilers. A patch for [5678kqv]c
will be hitting sources soon. Stay tuned.
Anthony
Anthony Martin
2011-12-15 02:59:45 UTC
Permalink
that's a little tidier, but still not right. the original
pswt.c code was fine (or nearly so). the problem is
actually in 8c's handling of 64-bit values and registers.
I'm not sure I understand entirely. Could you
elaborate this a bit? Also I'm a bit confused
about how uvlongs are handled in 8c. Regalloc
seems to use D_F0 for signed vlongs which works
fine with the AFMOVV instructions but IIRC that
only works for signed 64-bit values. To use an
unsigned value there would have to be some sort
of pre- and post-processing before a load or
store into the FP register. I don't see code
for that anywhere. Did I miss it?

Any help is appreciated.

Thanks,
Anthony
Charles Forsyth
2011-12-15 09:02:04 UTC
Permalink
Reply-to wasn't quite right. Anyway, it's probably easiest to carry on off
the list for a while.

Anthony Martin
2011-12-13 13:57:15 UTC
Permalink
Post by Lucio De Re
New features in Go require a new function in the reflect.c module
(src/cmd/gc/reflect.c). The C compiler (8c, in this case) reports an
8c -I/go/include -I/go/386/include -FTVw ../gc/reflect.c
../gc/reflect.c:987 switch expression must be integer
This is a bit of a stumbling block. I'm hoping there's someone on
this mailing list that can address this problem quicker than it would
be possible for me. More details off line.
Yup. 8c won't allow this. If you we're using 6c
you could have a vlong in a switch expression.

I sent out a CL for this:
https://codereview.appspot.com/5486049/

Anthony
Continue reading on narkive:
Loading...