Skip to content

Conversation

@ATrivialAtomic
Copy link
Contributor

This PR changes #define ASSIGN_CHECK_VAL(var, str, minval) to compare val > DBL_MAX instead of val > UINT_MAX.

This fixes an issue where, when mem_limit= exceeds 4.29G, the resulting return from unit_evaluate_dbl will exceed UINT_MAX limit and return an unexpected error.

`unit_evaluate_dbl()` returns a double and in certain cases, the returned val may exceed UINT_MAX, causing an unexpected error.
@MartinPulec
Copy link
Collaborator

I got the point. I understand that for mem_limit, 4 GiB may not be sufficient in general.

But the comparison to DBL_MAX in doubles will be AFAIK almost always true (unless the val is INFINITY; maybe also some other special dbl values). As this particular check there is mainly not to overflow the destination type, wouldn't be better to compare to the maximal value of the dst type instead, eg. std::numeric_limits<typeof var>::max()?

@MartinPulec
Copy link
Collaborator

Nevermind, I think that I can merge is as is and I'll improve it thereafter.

@MartinPulec MartinPulec merged commit f751cb2 into CESNET:master Nov 21, 2025
5 checks passed
MartinPulec added a commit that referenced this pull request Nov 21, 2025
check maximal value to fit the destination target type

Note: the `nextafter(..., -INF)` is used to represent a value of type
max that is also representable by double. Depending on the rounding
mode, eg. `(double) LLONG_MAX` may round up - in this case
9223372036854775807 becomes ..808.

improves <#473>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants