[PATCH] Fix for Bug 15290 - Segmentation fault during template instantiation

Ismail Pazarbasi ismail.pazarbasi at gmail.com
Thu Feb 21 13:53:14 PST 2013


Hi,

when operand of a noexcept operator in a friend function definition
involves a member of a template class enclosing the friend definition,
Clang casts current context to either a CXXMethodDecl or a
CXXRecordDecl. Since friend function is neither of these, cast fails.
The same test in a non-template class works fine.

The first patch tries to retrieve the lexical parent of the function
definition (per class.friend/p6-7), which is expected to be a record
type. A test is also provided (also, pasting below for reference).

template<typename T>
class noexcept_member_operand_at_friend_definition {
  T v_;
  friend int add_to_v(noexcept_member_operand_at_friend_definition &t)
noexcept(noexcept(v_ + 42))
  {
    return t.v_ + 42;
  }
};

void this_expr()
{
  noexcept_member_operand_at_friend_definition<int> t;
  add_to_v(t);
}

The second patch is a minor one; it merges two if statements that have
the same condition.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-for-Bug-15290-Segmentation-fault-during-template.patch
Type: application/octet-stream
Size: 2268 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130221/95e3dd6a/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Merged-two-subsequent-if-statements.patch
Type: application/octet-stream
Size: 1197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130221/95e3dd6a/attachment-0001.obj>


More information about the cfe-commits mailing list