Fix: avoid writer issues with ranges returning __int128 from Ranges::size#333
Fix: avoid writer issues with ranges returning __int128 from Ranges::size#333
__int128 from Ranges::size#333Conversation
|
The following performance differences (this branch vs target branch) have been measured: |
0873ae3 to
ade2ae6
Compare
|
The following performance differences (this branch vs target branch) have been measured: |
|
ping @timokoch if you have 5 minutes some day. Should not take longer. |
|
Since it's a narrowing conversion it could at some point lead to a nasty bug I guess (once someone actually uses an extremely large range). But adding full support for |
|
yeah I also thought it could be sketchy, that is why I requested a review. I doubt that it will really occur in practice, but if it does it'd be hard to track down. I will have a look at the use case again to see why this actually returns This was a pragmatic "fix" that would probably work in 99% of the cases. The amount of cells/vertices you need for the narrowing to kick in is huge... |
In one application (using
CGALwith the exact kernel) we ran into the case that for a given range,Ranges::sizereturned an__int128withgcc. In particular,Ranges::size(grid_points)returned an__int128when determining the number of points in the grid. This led to a compiler error because parsing to string for this data type didn't work, which is required to write the number of points into a vtk file.This PR changes the result type of
Ranges::sizetostd:.size_t. That is, in the mentioned case there is some precision loss. I'm not entirely sure why an__int128was returned in this case. The standard does not specify the return type ofstd::ranges::size, but I believe most.size()functions of the standard library returnstd::size_t. I guess it's fine to simply cast to anstd::size_tin this case. On typical architectures, it would only break for an insane amount of points/cells in the grid, I suppose.