Boost logo

Boost :

From: Ruben Perez (rubenperez038_at_[hidden])
Date: 2024-11-20 10:18:22


On Tue, 19 Nov 2024 at 23:04, Klemens Morgenstern via Boost
<boost_at_[hidden]> wrote:
>
> On Tue, Nov 19, 2024 at 6:26 PM Klemens Morgenstern <
> klemensdavidmorgenstern_at_[hidden]> wrote:
>
> >
> >
> > On Tue, Nov 19, 2024 at 6:13 PM Alexander Grund via Boost <
> > boost_at_[hidden]> wrote:
> >
> >> >> maybe a related question - how to you handle overflows - for example
> >> >> reading a too large value into a float?
> >> > That's not supported, you'll need to provide a double or a 64 bit int.
> >> What do you mean by "not supported"? What happens when you read a value
> >> larger than INT_MAX to an int? Or a value exceeding FLOAT_MAX but still
> >> using a float?
> >> Will those be silently truncated, UB in case of int, wrapped to inf for
> >> float?
> >>
> >
> > It won't compile. You can't read into an `int` implicitly.
> >
>
> Correction: I misremembered that part and didn't double check.
> You can read into an int implicitly, but you cannot read into a float, only
> double.
>
> So you can get an integer overflow if you're not careful.

I think that the library should be checking it and emitting an error, then.

>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk