https://github.com/keinflue created 
https://github.com/llvm/llvm-project/pull/176619

An assertion incorrectly treated difference in _Atomic qualification as 
different types for the purpose of verifying a perfect match in overload 
resolution in C++.

Fixes #170433

>From 0ea199e0bf84b5f287c750ec7083c61852534c8e Mon Sep 17 00:00:00 2001
From: keinflue <[email protected]>
Date: Sun, 18 Jan 2026 01:05:45 +0100
Subject: [PATCH] [clang] Don't assert on perfect overload match with _Atomic

An assertion incorrectly treated difference in _Atomic qualification as
different types for the purpose of verifying a perfect match in overload
resolution in C++.

Fixes #170433
---
 clang/docs/ReleaseNotes.rst           |  1 +
 clang/include/clang/Sema/Overload.h   |  6 +++---
 clang/test/SemaCXX/crash-GH170433.cpp | 16 ++++++++++++++++
 3 files changed, 20 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/SemaCXX/crash-GH170433.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b75715e873c50..59dd2d239391e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -147,6 +147,7 @@ Miscellaneous Clang Crashes Fixed
 - Fixed a crash when attempting to jump over initialization of a variable with 
variably modified type. (#GH175540)
 - Fixed a crash when using loop hint with a value dependent argument inside a
   generic lambda. (#GH172289)
+- Fixed a crash in C++ overload resolution with ``_Atomic``-qualified argument 
types. (#GH170433)
 
 OpenACC Specific Changes
 ------------------------
diff --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index cc9be00e9108c..ec29d45c0aa58 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -444,13 +444,13 @@ class Sema;
           if (auto *N = T->getAs<MemberPointerType>();
               N && N->isMemberFunctionPointer())
             T = C.getDecayedType(N->getPointeeType());
-          return T;
+
+          return T.getAtomicUnqualifiedType();
         };
         // The types might differ if there is an array-to-pointer conversion
         // an function-to-pointer conversion, or lvalue-to-rvalue conversion.
         // In some cases, this may happen even if First is not set.
-        assert(C.hasSameUnqualifiedType(Decay(getFromType()),
-                                        Decay(getToType(2))));
+        assert(C.hasSameType(Decay(getFromType()), Decay(getToType(2))));
 #endif
         return true;
       }
diff --git a/clang/test/SemaCXX/crash-GH170433.cpp 
b/clang/test/SemaCXX/crash-GH170433.cpp
new file mode 100644
index 0000000000000..9fedafafd89fa
--- /dev/null
+++ b/clang/test/SemaCXX/crash-GH170433.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -verify %s
+
+// https://github.com/llvm/llvm-project/issues/170433
+
+// expected-no-diagnostics
+
+void f(double);
+
+template <class = int>
+void f(double);
+
+_Atomic double atomic_value = 42.5;
+
+void test() {
+    f(atomic_value);
+}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to