[LLVMdev] clang : assert ignored with -O1 ?!

Óscar Fuentes ofv at wanadoo.es
Fri Nov 30 13:35:12 PST 2012


Frédéric Heitzmann <frederic.heitzmann at gmail.com> writes:

> I work on an embedded target, in which function assert is an infinite
> while(1) loop.
> It is a common technique to set a breakpoint in the loop, in case some
> error occurs while debugging.
>
> It looks like clang simply *removes* any call to assert when compiling
> with -O1 (not -O0).
> note 1 : the name 'assert' is not the problem.
> note 2 : if the while(1) loop has some side effect, like increasing a
> global variable, it is not removed.
>
> => Is it a normal behaviour of -O1 ? I did not find any documentation
> about it.

Maybe the thread that started with this message is relevant to you?

Subject: Is infinite empty loop dead code?
To: llvmdev at cs.uiuc.edu
Date: Tue, 13 Nov 2012 23:23:02 -0800

http://thread.gmane.org/gmane.comp.compilers.llvm.devel/55666

Please note that clang has its own mailing list, although your case is
quite relevant to LLVM too.

[snip]




More information about the llvm-dev mailing list