This is the mail archive of the
mailing list for the GCC project.
Re: confused at code generation for a empty loop
- From: Tim Prince <tprince at computer dot org>
- To: PRC <panruochen at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Fri, 30 Nov 2007 06:17:53 -0800
- Subject: Re: confused at code generation for a empty loop
- References: <firstname.lastname@example.org>
> while( flag == 0 ) ;
> I wonder why gcc generates code for a empty loop like that. Is it a bug or for optimization in some case?
This subject has been debated at length, and some programmers rely on
the current gcc treatment. More programmers rely on loops whose exit
condition should not be optimized away, but does get "optimized" away by
unsafe "optimizations" by certain compilers, including gcc -ffast-math.