http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51971

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-24 
13:01:03 UTC ---
GCC explicitely allows you to use const/pure to enable CSE even if it would
not consider the function const/pure itself (thus, if you are happy to
loose a second assert (), or a debug printf).

About returning normally it wants to exclude side-effects that happen
via the return, such as if the function calls longjmp/fork (return twice).
It also wants to exclude functions that do not return because they loop
infinitely.  For example

int foo (int b)
{
  if (b) while (1);
  return b;
}

is not const, as GCC would, if you declare it so, happily remove

  foo (1);

as dead code (GCC will do so for all pure/const functions if the result
is not needed).

Reply via email to