Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: one imperfection #41835

Closed
go101 opened this issue Oct 7, 2020 · 7 comments
Closed

spec: one imperfection #41835

go101 opened this issue Oct 7, 2020 · 7 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@go101
Copy link

go101 commented Oct 7, 2020

The line in spec is not accurate:

var p = 1<<s == 1<<33         // illegal if ints are 32bits in size: 1 has type int, but 1<<33 overflows int

The line is always legal.

@go101
Copy link
Author

go101 commented Oct 7, 2020

Sorry, it looks the comment talks about the 2nd "1".

@go101 go101 closed this as completed Oct 7, 2020
@go101
Copy link
Author

go101 commented Oct 7, 2020

There is still an imperfection: a[1.0<<s] will always panic. So it would be better to change the comment from

// 1.0 has type int; x == a[0] if ints are 32bits in size

to

// 1.0 has type int; Evaluated to x = a[0] if ints are 32bits in size

@go101 go101 reopened this Oct 7, 2020
@go101 go101 changed the title spec: one inaccuracy spec: one imperfection Oct 7, 2020
@ianlancetaylor
Copy link
Contributor

I'm not sure any change is required here, but CC @griesemer .

@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 7, 2020
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Oct 7, 2020
@go101
Copy link
Author

go101 commented Oct 7, 2020

It is that a[0] is a non-existing element if ints are 32bits in size.

@ianlancetaylor
Copy link
Contributor

Understood, I just don't think it is unclear.

@griesemer
Copy link
Contributor

I agree with @ianlancetaylor - this seems clear enough.

That said, the change I'd make is declare a separate independent array, rather than using a that's declared on the next line. Then there's no confusion.

I will make the change as it's trivial.

@gopherbot
Copy link

Change https://golang.org/cl/260398 mentions this issue: spec: make a shift example slightly clearer

@golang golang locked and limited conversation to collaborators Oct 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants