This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Empty loop elimination in 4.0 ?
Robert Dewar <dewar@adacore.com> writes:
> Oscar Fuentes wrote:
>
>>>I think it is always a good idea to generate a warning
>>>when an empty loop is detected (whether or not it is
>>>eliminated), since this is either a timing loop, or it
>>>is likely a bug.
>
>> Not in C++.
>
> Can you say why?
> Note that I do not mean an empty body, I mean an empty loop.
> Why shoudl a completely empty loop be interesting in C++
In generic programming, you can end with this:
template <typename T> sometype foo(T t) {
// ...
for(....) {
somefunc(t);
}
// ...
}
`somefunc' can be overloaded on such a way that it is a no-op for some types.
This is not pathological nor exotic.
--
Oscar