|
|
Subscribe / Log in / New account

Stagefrightening

Stagefrightening

Posted Aug 2, 2015 11:14 UTC (Sun) by kleptog (subscriber, #1183)
In reply to: Stagefrightening by mathstuf
Parent article: Stagefrightening

In gcc you can just say: if(__builtin_add_overflow(foo, bar, &sum)) { error("Overflow"); }

See: https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Built...

Other compilers have similar features: https://msdn.microsoft.com/en-us/library/windows/desktop/...

It's not these these features don't exist, it's that (a) they're not standardised and (b) people aren't using them.


to post comments

Stagefrightening

Posted Aug 2, 2015 13:03 UTC (Sun) by mathstuf (subscriber, #69389) [Link] (1 responses)

Yep, much better interface there since you don't waste the computation.

> It's not these these features don't exist, it's that (a) they're not standardised

Why would this matter for, at least, the kernel?

Stagefrightening

Posted Aug 3, 2015 21:08 UTC (Mon) by kleptog (subscriber, #1183) [Link]

> > It's not these these features don't exist, it's that (a) they're not standardised

>Why would this matter for, at least, the kernel?

For the kernel it doesn't matter so much, other than it's new (GCC 5.0 new to be precise). But you could probably whip these up in an afternoon in assembly if you wanted to, I think it's telling that this hasn't happened. You don't need compiler support to make these functions, it just makes it easier. The kernel devs could have implemented it years ago if they wanted to.

For all user space applications not being standardised makes it hard because you'd really rather not rely on special compiler features.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds