<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Clang should report that char[] is NOT trivially destructible"
   href="https://bugs.llvm.org/show_bug.cgi?id=33232">33232</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang should report that char[] is NOT trivially destructible
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>4.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>sfinae@hotmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18542" name="attach_18542" title="Self-contained test case">attachment 18542</a> <a href="attachment.cgi?id=18542&action=edit" title="Self-contained test case">[details]</a></span>
Self-contained test case

For historical (TR1-era) reasons, MSVC's STL implements
std::is_trivially_destructible with __has_trivial_destructor(). We do so
directly, with no additional logic, so we expect this builtin to follow the
Standard's specification exactly. C1XX provides such behavior, but Clang
doesn't.

If it were absolutely necessary, we could change MSVC's STL to implement
std::is_trivially_destructible with an __is_trivially_destructible builtin, but
then Clang would have to implement that - and it would be a headache for other
reasons.

C:\Temp>type meow.cpp
/***
N4659 23.15.4.3 [meta.unary.prop]:

Template: template <class T> struct is_destructible;
Condition: Either T is a reference type, or T is a complete object type for
which the expression
declval<U&>().~U() is well-formed when treated as an unevaluated operand
(Clause 8),
where U is remove_all_extents<T>.
Preconditions: T shall be a complete type, cv void, or an array of unknown
bound.

Template: template <class T> struct is_trivially_destructible;
Condition: is_destructible_v<T> is true and the indicated destructor is known
to be trivial.
Preconditions: T shall be a complete type, cv void, or an array of unknown
bound.

Template: template <class T> struct is_nothrow_destructible;
Condition: is_destructible_v<T> is true and the indicated destructor is known
not to throw any exceptions (8.3.7).
Preconditions: T shall be a complete type, cv void, or an array of unknown
bound.
***/

template <typename T> struct is_destructible {
    static constexpr bool value = __is_destructible(T);
};

template <typename T> struct is_trivially_destructible {
    static constexpr bool value = __has_trivial_destructor(T);
};

template <typename T> struct is_nothrow_destructible {
    static constexpr bool value = __is_nothrow_destructible(T);
};

int main() {
    static_assert(!is_destructible<char[]>::value, "BOOM");
    static_assert(!is_destructible<const char[]>::value, "BOOM");
    static_assert(!is_destructible<volatile char[]>::value, "BOOM");
    static_assert(!is_destructible<const volatile char[]>::value, "BOOM");

    static_assert(!is_trivially_destructible<char[]>::value, "BOOM");
    static_assert(!is_trivially_destructible<const char[]>::value, "BOOM");
    static_assert(!is_trivially_destructible<volatile char[]>::value, "BOOM");
    static_assert(!is_trivially_destructible<const volatile char[]>::value,
"BOOM");

    static_assert(!is_nothrow_destructible<char[]>::value, "BOOM");
    static_assert(!is_nothrow_destructible<const char[]>::value, "BOOM");
    static_assert(!is_nothrow_destructible<volatile char[]>::value, "BOOM");
    static_assert(!is_nothrow_destructible<const volatile char[]>::value,
"BOOM");
}

C:\Temp>cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.11.25326 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]

C:\Temp>cl /EHsc /nologo /W4 meow.cpp
meow.cpp

C:\Temp>clang-cl -v
clang version 4.0.0 (tags/RELEASE_400/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: S:\WCFB01\vctools\NonShip\ClangLLVM\bin

C:\Temp>clang-cl /EHsc /nologo /W4 meow.cpp
meow.cpp(37,5):  error: static_assert failed "BOOM"
    static_assert(!is_trivially_destructible<char[]>::value, "BOOM");
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
meow.cpp(38,5):  error: static_assert failed "BOOM"
    static_assert(!is_trivially_destructible<const char[]>::value, "BOOM");
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
meow.cpp(39,5):  error: static_assert failed "BOOM"
    static_assert(!is_trivially_destructible<volatile char[]>::value, "BOOM");
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
meow.cpp(40,5):  error: static_assert failed "BOOM"
    static_assert(!is_trivially_destructible<const volatile char[]>::value,
"BOOM");
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 errors generated.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>