[LLVMdev] Is infinite empty loop dead code?
Joshua Cranmer
pidgeot18 at gmail.com
Wed Nov 14 10:56:32 PST 2012
On 11/14/2012 2:22 AM, Shuxin Yang wrote:
> I do some google, I cannot find the answer...
> I check C std, I cannot find answer either.
The C++11 standard explicitly allows compilers to assume that all loops
will eventually terminate:
[intro.multithread] 24:
The implementation may assume that any thread will eventually do one of
the following:
— terminate,
— make a call to a library I/O function,
— access or modify a volatile object, or
— perform a synchronization operation or an atomic operation.
[ Note: This is intended to allow compiler transformations such as
removal of empty loops, even when
termination cannot be proven. —end note ]
I don't know if C11 has a similar statement, but C99 has a statement
which is ambiguous in this regard (it only refers to a requirement upon
program termination).
There's a blog post by John Regehr on this topic:
<http://blog.regehr.org/archives/161>.
--
Joshua Cranmer
News submodule owner
DXR coauthor
More information about the llvm-dev
mailing list