[LLVMdev] Is infinite empty loop dead code?

陳韋任 (Wei-Ren Chen) chenwj at iis.sinica.edu.tw
Wed Nov 14 00:56:34 PST 2012


On Wed, Nov 14, 2012 at 12:22:33AM -0800, Shuxin Yang wrote:
> I do some google, I cannot find the answer...
> I check C std, I cannot find answer either.
> 
> Delete infinite empty loop is boring, but if C/C++ lawyers could tell it 
> is safe to to so,
> it would obviate the need to prove a non-countable loop infinite or not 
> before
> DCE can delete it.
> 
> That is the answer I'm waiting for to delete a disgusting dead 
> non-countable loop in my way.

  Perhaps Duncan will give you a proper keyword to search in GCC/LLVM
ML archieve. I found a page [1], and iiuc, the C standard allow the
implementation (i.e., the compiler) to remove such empty infinite loop.

Regards,
chenwj

[1]
https://www.securecoding.cert.org/confluence/display/seccode/MSC40-C.+Do+not+use+an+empty+infinite+loop

-- 
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj




More information about the llvm-dev mailing list