[LLVMdev] Is infinite empty loop dead code?

Krzysztof Parzyszek kparzysz at codeaurora.org
Wed Nov 14 11:01:57 PST 2012


On 11/14/2012 12:07 PM, Shuxin Yang wrote:
>
> If it is reachable, that is bit difficult to tell. Now that C std
> already give compiler such permit, perhaps we don't have to keep
 > in sync with gcc.

 From the C standard (well, draft):

----
6.8.5 Iteration statements
[...]

An iteration statement whose controlling expression is not a constant 
expression, that performs no input/output operations, does not access 
volatile objects, and performs no synchronization or atomic operations 
in its body, controlling expression, or (in the case of a "for" 
statement) its expression-3, may be assumed by the implementation to 
terminate.
----

This still doesn't allow you to remove "while(1) {}", since the 
controlling expression *is* a constant expression.


-Krzysztof


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation



More information about the llvm-dev mailing list