This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch c++]: Fix 61228 - noexcept(expression) causes internal compiler error


Hi,

following patch fixes reported issue.
Tested for x86_64-w64-mingw32.  Ok for apply?

Regards,
Kai

ChangeLog

2014-12-12  Kai Tietz  <ktietz@redhat.com>

    PR c++/61228
    * call.c (set_flags_from_callee): Assume no throw
    by deferred noexcept.

2014-12-12  Kai Tietz  <ktietz@redhat.com>

    PR c++/61228
    * g++.dg/cpp0x/pr61228.C: New file.

ChangeLog testcase/g++.dg/cpp0x as pr61228.C:
// { dg-do run { target c++11 } }

#include <cctype>
#include <algorithm>

template<int (& F)(int)>
constexpr int safeCtype(unsigned char c) noexcept(noexcept(F(c)))
{ return F(c); }

int main()
{
  const char t[] = "a";
  std::find_if(t, t + 1, safeCtype<std::isspace>);
  return 0;
}

Index: call.c
===================================================================
--- call.c      (Revision 218681)
+++ call.c      (Arbeitskopie)
@@ -335,11 +335,17 @@ set_flags_from_callee (tree call)
 {
   int nothrow;
   tree decl = get_callee_fndecl (call);
+  tree spec;

   /* We check both the decl and the type; a function may be known not to
      throw without being declared throw().  */
-  nothrow = ((decl && TREE_NOTHROW (decl))
-            || TYPE_NOTHROW_P (TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (call)))));
+  nothrow = (decl && TREE_NOTHROW (decl));
+  if (!nothrow)
+    {
+      spec = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (call)));
+      nothrow = (!DEFERRED_NOEXCEPT_SPEC_P (TYPE_RAISES_EXCEPTIONS (spec))
+                 && TYPE_NOTHROW_P (spec));
+    }

   if (!nothrow && at_function_scope_p () && cfun && cp_function_chain)
     cp_function_chain->can_throw = 1;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]