This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Is it OK that gcc optimizes away overflow check?


On 07/26/2011 11:35 AM, Andrew Haley wrote:

> Consider
> 
>   for (i = 0; i < limit; i++)
>     f(i * 2);
> 
> which can be rewritten to
> 
>   tmp = limit * 2;
>   for (i = 0; i < tmp; i++)
>     f(i);

duh.

  int tmp = limit * 2;
  for (i = 0; i < tmp; i += 2)
    f(i);

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]