[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87k2tuoadi.fsf@rasmusvillemoes.dk>
Date: Mon, 20 Jul 2015 22:13:45 +0200
From: Rasmus Villemoes <linux@...musvillemoes.dk>
To: Sasha Levin <sasha.levin@...cle.com>
Cc: mingo@...nel.org, akpm@...ux-foundation.org,
linux-kernel@...r.kernel.org
Subject: Re: [RFC 1/3] compiler.h: enable builtin overflow checkers and add fallback code
On Mon, Jul 20 2015, Sasha Levin <sasha.levin@...cle.com> wrote:
> On 07/19/2015 07:17 PM, Rasmus Villemoes wrote:
>> Last year, Sasha Levin suggested adding wrappers for the
>> __builtin_*_overflow functions introduced with gcc 5.1 (based on
>> similar, but type-specific, functions in clang). This is another
>> attempt at providing such wrappers and fallback code for older compilers.
>
> What's the difference between this version and the one Linus essentially
> rejected?
Assuming you're referring to
http://thread.gmane.org/gmane.linux.kernel/1838832 (the latest I could
find, and the one Linus "[didn't] like"):
I've tried to ensure that the fallback code has the same semantics as
the gcc builtins [1] (in particular, to handle all kinds of overflow) -
I think it would be rather dangerous if the types of overflow detected
depended on the gcc version.
The fallback code in the version referred to above had a number of
problems:
* relies on UB for signed types
* both false positives and false negatives (because it more or less
implicitly assumed that all values are positive)
* even for unsigned types, plain a+b<a is broken for types narrower than
int
It's also inconvenient for the user to have to pass the appropriate
type_max value to the mul_overflow checker.
Rasmus
[1] though with the extra requirement of all three arguments having the
same type.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists