-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fatal.nim(48) sysFatal Error: unhandled exception: value out of range: 4294967295 [RangeError] #11895
Comments
This version is working correctly: |
There is an issue template that is supposed to guide you on how to properly report an issue. It has an example on how to write code examples and how to format the output. Please use it. |
Cannot reproduce on my machine with devel from yesterday, as of commit 61c66ab Also note that |
Build from github source :
My machine is 32 bit and has sizeof(uint)=sizeof(uint32)=4 |
this test should be reevaluated after this PR has been merged: #11701 |
This test was performed now from the current devel branch. Maybe I'm doing something wrong.. |
No, you did everything right. The link is a branch I recently worked on (not yet merged into devel). There I worked a lot on the range checks that are implemented in the compiler. I can't guarantee that this BUG is fixed there, but it is possible. |
@citrusn can you try again? My PR got merged. For my machine your example works now as expected. |
This code is good: type
REQUEST_RQ_TYPE* {.size: sizeof(uint32).} = enum
RRT_FORCE_DWORD = -1, #0xFFFFFFFF
RRT_GET = 1,
RRT_POST = 2,
RRT_PUT = 3,
RRT_DELETE = 4#,
#RRT= 4294967295
#RRT = 0xFFFFFFFF
echo cast[uint32](RRT_FORCE_DWORD) Output:
but, this don't works: type
REQUEST_RQ_TYPE* {.size: sizeof(uint32).} = enum
#RRT_FORCE_DWORD = -1, #0xFFFFFFFF
RRT_GET = 1,
RRT_POST = 2,
RRT_PUT = 3,
RRT_DELETE = 4,
#RRT= 4294967295
RRT = 0xFFFFFFFF
echo cast[uint32](RRT_FORCE_DWORD) #, ' ', RRT_FORCE_DWORD.uint32
|
This code is also good: type
REQUEST_RQ_TYPE* {.size: sizeof(uint32).} = enum
RRT_FORCE_DWORD = 0xFFFFFFFF'i32,
RRT_GET = 1,
RRT_POST = 2,
RRT_PUT = 3,
RRT_DELETE = 4
#RRT_FORCE_DWORD = 0xFFFFFFFF'u32 # but not this |
What if you use type
REQUEST_RQ_TYPE* {.size: sizeof(uint32).} = enum
RRT_GET = 1'u32,
RRT_POST = 2,
RRT_PUT = 3,
RRT_DELETE = 4
RRT_FORCE_DWORD = 0xFFFFFFFF'u32 My guess is that it's because Nim tracks the value with int by default and 0xFFFFFFFF is not a valid int. I also know that the range check for literals changed after 0.19.6 because I used to test that in one of my libraries, probably stint |
This is a great idea, but it doesn't work right now. |
Nim Compiler Version 0.20.99 [Windows: i386]
Compiled at 2019-08-06
test.nim:
Error output:
The text was updated successfully, but these errors were encountered: