[Bug middle-end/19020] libcalls are removed (-ftrapv does not work)

steven at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sat Mar 1 10:54:00 GMT 2008



------- Comment #7 from steven at gcc dot gnu dot org  2008-03-01 10:50 -------
With trunk as of today, the test case of comment #0 does trap if optimization
is disabled. At -O, the libcall is optimized away, but the call to iaddv() from
main() is also optimized away because iaddv is found to be pure.  You must use
the result of iaddv() to avoid this:

#include <limits.h>

int __attribute__((noinline))
iaddv (int a, int b)
{
  return a + b;
}

int main(void)
{
  return iaddv (INT_MAX, 1);
}


-- 


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



More information about the Gcc-bugs mailing list