[all-commits] [llvm/llvm-project] 0ce6d6: [Sema] List conversion validate character array.

mordante via All-commits all-commits at lists.llvm.org
Sat Oct 3 05:34:22 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 0ce6d6b46eb7040283ad0800c5533672fbfb9bac
      https://github.com/llvm/llvm-project/commit/0ce6d6b46eb7040283ad0800c5533672fbfb9bac
  Author: Mark de Wever <koraq at xs4all.nl>
  Date:   2020-10-03 (Sat, 03 Oct 2020)

  Changed paths:
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Sema/SemaInit.cpp
    M clang/lib/Sema/SemaOverload.cpp
    M clang/test/CXX/drs/dr14xx.cpp
    M clang/test/SemaObjCXX/overload.mm

  Log Message:
  -----------
  [Sema] List conversion validate character array.

The function `TryListConversion` didn't properly validate the following
part of the standard:

    Otherwise, if the parameter type is a character array [... ]
    and the initializer list has a single element that is an
    appropriately-typed string literal (8.5.2 [dcl.init.string]), the
    implicit conversion sequence is the identity conversion.

This caused the following call to `f()` to be ambiguous.
    void f(int(&&)[1]);
    void f(unsigned(&&)[1]);

    void g(unsigned i) {
      f({i});
    }

This issue only occurs when the initializer list had one element.

Differential Revision: https://reviews.llvm.org/D87561




More information about the All-commits mailing list