[llvm-bugs] [Bug 51171] New: SIGSEGV at DeduceTemplateArgumentsByTypeMatch

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 22 12:08:34 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51171

            Bug ID: 51171
           Summary: SIGSEGV at  DeduceTemplateArgumentsByTypeMatch
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ivan.murashko at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Created attachment 25049
  --> https://bugs.llvm.org/attachment.cgi?id=25049&action=edit
The crash reproducer

There is a SIGSEGV (NULL dereference) at DeduceTemplateArgumentsByTypeMatch as
soon as FunctionType parameter passed into the function is NULL. See reproducer
at the attachment

The possible fix for the problem is

--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4346,7 +4346,7 @@ Sema::TemplateDeductionResult
Sema::DeduceTemplateArguments(
     HasDeducedReturnType = true;
   }

-  if (!ArgFunctionType.isNull()) {
+  if (!ArgFunctionType.isNull() && !FunctionType.isNull()) {
     unsigned TDF =
         TDF_TopLevelParameterTypeList | TDF_AllowCompatibleFunctionType;
     // Deduce template arguments from the function type.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210722/d9a2842c/attachment.html>


More information about the llvm-bugs mailing list