Live data from Hacker News

C++ float-to-int conversion can be undefined behavior

kttnr.net

21–22 of 22 posts

Re: C++ float-to-int conversion can be undefined behavior

#21
post #5

Earlier quoted context omitted.

C++ was designed as an universal way of writing low level system code. It has some abstractions above C, but still allowing for all kinds of optimizations. (Think using a class vs a template, similar abstraction different impact). To use C++ to code user programs is the actual mistake. Think about assembly. Should assembly also be safe in all calls? That will make everything slower, and consume way more energy. Will…

I thought C++ was designed to fit all sorts of applications. There is many GUI libraries for C++ for example, and the language has all the capabilities to add abstractions for making these sorts of libraries easy to work with. I think you could argue that C was made for low level code, since the working group seems to be focussing on making the core of the language more usable instead of allowing for abstractions tha…

> to fit all sorts of applications.

Yes. In 1985. Processor allow for things like garbage collectors that in the 80s would have been a terrible waste for most uses. Most game developers will never create a 3d engine while 80s developer will do their, 2d engines, by themselves.

Assembly was created to be able to create any kind of applications. In the 50s that made sense, not in the 80s.

Re: C++ float-to-int conversion can be undefined behavior

#22

Earlier quoted context omitted.

> It also means that the behavior needs to be stable across time I don't think IB has to be stable over time? For instance, whether and which extended integer types exist is IB and that has definitely changed over time. > and that tools cannot report this behavior as a bug. It's absolutely possible to report IB as a bug (or even fully-specified behavior, as demonstrated by -fsanitize=unsigned-integer-overflow or -fsa…

IB is something that developers can rely on. If it changes out from under you thats a bug.

To the extent that implementations promise, sure. But that is beyond the scope of the standard.
Post reply on HN