bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GCC optimizes integer overflow: bug or feature?


From: Florian Weimer
Subject: Re: GCC optimizes integer overflow: bug or feature?
Date: Tue, 19 Dec 2006 11:20:19 +0100

* Andrew Pinski:

> A simple loop like:
> int foo ()
> {
>   int a[N];
>   int i;
>   int n;
>
>   for (i = 0; i <= n; i++)
>       ca[i] = 2;
> }
>
> we cannot find how many iterations it runs without knowing that signed
> types overflow.

In this case, the assumption is not needed because the lack of
overflow can be inferred from the validity of the expression ca[i] for
all relevant i.  However, in the general case, such information might
not be available.  I wonder if it is feasible to duplicate the loop
code, once for positive n, and once for negative, or if this would
lead to too much code bloat in real-world applications.

By the way, as I've tried to describe here:
<http://cert.uni-stuttgart.de/advisories/c-integer-overflow.php>
variable range tracking can result in reintroduction of
supposedly-fixed security vulnerabilities. 8-(




reply via email to

[Prev in Thread] Current Thread [Next in Thread]