This is the mail archive of the gcc@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: Empty loop elimination in 4.0 ?


Michael Veksler wrote:-

> Maybe in C, but not in C++ when you may have generic code
> that is translated to empty loops.
> 
> When you pass a generic visitor (visitor in the old GTL sense), it has a
> set
> of callbacks. These callbacks are inline functions, some of them are empty.
>   template <class V>
>   f(V v)
>   {
>      for(....)  v.Do1();
>      for(....)  v.Do2();
>   }
> 
> Whoever defines 'f' does not care if V::Do1() is empty. Morever,
> nobody wants to write special code for the case when V::Do1() is
> empty. It is assumed that the compiler is smart enough to get
> rid of the loop.

To the front end these are not empty loops.  Such warnings belong
in the front end not the optimizers.
 
> Another example, with C macros. I assume that with -DNDEBUG
> assert(x) is empty:
> 
> for (p: iterates over elements)
>   assert(p->value != NULL);  /* Will warn with -DNDEBUG */
> 
> /* Should I add "#ifndef NDEBUG" to protect the loop? */

Any warning can be triggered by certain uses of macro expansions.
That is not usually used as an argument to suppress them.

Neil.


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