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

Can't use syscall.EPOLLET value: constant overflows #832

Closed
alberts opened this issue Jun 3, 2010 · 2 comments
Closed

Can't use syscall.EPOLLET value: constant overflows #832

alberts opened this issue Jun 3, 2010 · 2 comments

Comments

@alberts
Copy link
Contributor

@alberts alberts commented Jun 3, 2010

What steps will reproduce the problem?

var epevent syscall.EpollEvent  
epevent.Events |= syscall.EPOLLET

What is the expected output? What do you see instead?

Code fails to compile:

constant -2147483648 overflows uint32

What is your $GOOS?  $GOARCH?

GOARCH="amd64"
GOOS="linux"

Which revision are you using?  (hg identify)

95355ede92ce tip
@alberts
Copy link
Contributor Author

@alberts alberts commented Jun 3, 2010

Comment 1:

A possible workaround is:
epevent.Events |= syscall.EPOLLET & 0xffffffff
but maybe something can be done in the syscall package or the language to make this bit 
mask unnecessary.
@griesemer
Copy link
Contributor

@griesemer griesemer commented Jun 3, 2010

Comment 2:

This is not a language or compiler problem, the value syscall.EPOLLET is negative
(-0x80000000) and thus 
cannot be represented as (or'ed to) a uint32 w/o loss of precision.
Your "work-around" is the correct approach in this case, in Go one has to be explicit
about loosing precision 
with constants.
Alternatively, perhaps the constant syscall.EPOLLET shouldn't be negative in the first
place - but that would be 
an issue with godefs as this package is automatically generated.
Closing for now as this works as intended.

Status changed to WorkingAsIntended.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants