clang : assert ignored with -O1 ?!

Hi all,

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.

Frédéric Heitzmann <frederic.heitzmann@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?