diff --git a/gcc/except.cc b/gcc/except.cc index 9277a9a80c3..2080fcc22e6 100644 --- a/gcc/except.cc +++ b/gcc/except.cc @@ -2167,6 +2167,9 @@ expand_builtin_eh_return_data_regno (tree exp) return constm1_rtx; } + if (!tree_fits_uhwi_p (which)) + return constm1_rtx; + iwhich = tree_to_uhwi (which); iwhich = EH_RETURN_DATA_REGNO (iwhich); if (iwhich == INVALID_REGNUM) diff --git a/gcc/testsuite/gcc.dg/pr101195.c b/gcc/testsuite/gcc.dg/pr101195.c new file mode 100644 index 00000000000..7b219f80711 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr101195.c @@ -0,0 +1,8 @@ +/* PR middle-end/101195 */ +/* { dg-do compile } */ + +int +foo (void) +{ + return __builtin_eh_return_data_regno (-42); +}