Search Issue Tracker
Won't Fix
Votes
1
Found in
5.3.5f1
Issue ID
811096
Regression
No
Range(1, int.MaxValue) produces negative result
Steps to reproduce:
1. Open attached project.
2. Open scene named "main".
3. In the "Hierarchy" window select "Main camera".
4. The "Test (Script)" component shows that:
"int.MaxValue" is 2147483647.
"[Range(1, int.MinValue)]" is from 1 to -2147483648.
"[Range(1, int.MaxValue)]" is from 1 to -2147483648.
"[Range(0, 2147483584)]" is from 0 to -2147483648.
"[Range(0, 2147483583)]" is from 0 to 2147483520.
Expected result:
"[Range(1, int.MaxValue)]" should be from 1 to 2147483648.
Reproduced with:
5.1.0f3, 5.2.4f1, 5.3.5f1, 5.3.5p6, 5.4.0b25.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Editor crashes on StoredGraphicsBuffer::GetGfxBufferID when VFX Graph property is modified during Play Mode and Application.targetFrameRate is used to limit FPS
- Crash on NVAPI_Thunk when changing Player resolution while HDR display is used and Direct3D12 is set as the graphics API
- Only one out of multiple cameras is shown in the Play Mode while HDR display is used and Direct3D12 is set as the graphics API
- The "Paste Component as New" option is incorrectly displayed as active despite the action being prohibited
- "TLS Allocator ALLOC_TEMP_TLS" errors are thrown when unsuccessfully importing an FBX file
shubhamswaraj2021
Aug 18, 2020 15:56
good one <a href="https://www.lyricsauto.com">lyricsauto</a>
Aquablue
Feb 09, 2019 14:12
Unity 2018.3.x and the bug still exists.
Workaround: use [Range(0, int.MaxValue - 64)]
manarito
Dec 12, 2017 11:07
So doing further tests, the maximum number which can be used in a range before the behaviour happens is 2147483583, which I think is not fortuitous as 2147483647 - 2147483583 = 64 = 2^6
manarito
Dec 12, 2017 10:54
I was becoming crazy with this! Thankfully I found this bug report.
The issue is still there in Unity 2017.3, I honestly don't know how to fix it (in , even trying a max range using UInt32 gives a negative range.