Package: clang Version: 3.1-8 Severity: normal Tags: upstream patch fixed-upstream
upstream bug url: http://llvm.org/bugs/show_bug.cgi?id=13480 Dear Maintainer, The below code segfaults clang. This uses a C++11 feature that was not implemented in clang 3.0, and it has been fixed in trunk for 3.2. I am attaching a backported, slightly edited version of the patch. // compile with -std=c++11 struct String { String(const String&); String(String&); }; union Impl { String first; }; *** Please consider answering these questions, where appropriate *** * What led up to the situation? * What exactly did you do (or not do) that was effective (or ineffective)? * What was the outcome of this action? * What outcome did you expect instead? *** End of the template - remove these lines *** -- System Information: Debian Release: wheezy/sid Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.2.0-3-amd64 (SMP w/2 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages clang depends on: ii libc6 2.13-35 ii libclang-common-dev 3.1-8 ii libffi5 3.0.10-3 ii libgcc1 1:4.7.1-7 ii libllvm3.1 3.1-2 ii libstdc++6 4.7.1-7 ii libstdc++6-4.6-dev 4.6.3-11 Versions of packages clang recommends: ii llvm-3.1-dev 3.1-2 ii python 2.7.3~rc2-1 clang suggests no packages. -- no debconf information
>From 48191d0392dd4edbb8fb23acd6cbe96200a35a77 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer <benny....@googlemail.com> Date: Mon, 30 Jul 2012 15:53:26 +0000 Subject: [PATCH] Backport two patches from trunk to 3.1 Fix ambiguity detection in GetBestOverloadCandidateSimple. When performing the simplistic overload resolution for single-argument methods, don't check the best overload for ambiguity with itself when the best overload doesn't happen to be the first one. Fixes PR13480. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160961 91177308-0d34-0410-b5e6-96231b3b80d8 Use the location of the copy assignment when diagnosing classes that are nontrivial because of it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160962 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/DeclCXX.cpp | 4 ++-- lib/Sema/SemaDecl.cpp | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 114322b..14a540b 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -359,8 +359,8 @@ GetBestOverloadCandidateSimple( if (Cands[Best].second.compatiblyIncludes(Cands[I].second)) Best = I; - for (unsigned I = 1; I != N; ++I) - if (Cands[Best].second.compatiblyIncludes(Cands[I].second)) + for (unsigned I = 0; I != N; ++I) + if (I != Best && Cands[Best].second.compatiblyIncludes(Cands[I].second)) return 0; return Cands[Best].first; diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 1227e92..421a567 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -9213,10 +9213,9 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) { case CXXCopyAssignment: if (RD->hasUserDeclaredCopyAssignment()) { - // FIXME: this should use the location of the copy - // assignment, not the type. - SourceLocation TyLoc = RD->getLocStart(); - Diag(TyLoc, diag::note_nontrivial_user_defined) << QT << member; + SourceLocation AssignLoc = + RD->getCopyAssignmentOperator(0)->getLocation(); + Diag(AssignLoc, diag::note_nontrivial_user_defined) << QT << member; return; } break; -- 1.7.10.4