<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/56112>56112</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang doesn't report full stack trace for static_assert()
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          realazthat
      </td>
    </tr>
</table>

<pre>
    When triggering a static_assert within the standard library, clang prints a stack-trace of the instantiation that triggered the assert, but every file/line it lists in the trace is not in user code (rather, it is within stdlib), which makes it extraordinarily difficult to debug ( kinds of traces are very famously difficult to read in the first place, there is no reason to make it nearly impossible!).

In the code below, `const std::optional<std::vector<std::optional<Thing>>> &d = c;` is invalid instantiation because Thing is not copy constructible, and this forces the optional not to be copy constructible, yet the only possible thing to do here is to make a copy, so it asserts.

However, the error does not point to this line, and in a large amount of code I required creduce to pinpoint this.


> All information necessary to reproduce the problem.

> **The reduced test-case that triggers the bug. (symbol.cxx):** 
```
#include <vector>
#include <optional>


struct Thing {
  Thing() = delete;
  Thing(const Thing&) = delete;
  Thing& operator=(const Thing&) = delete;
  Thing& operator=( Thing&&);
  Thing(Thing&&);
};

void b() {
  std::vector<std::optional<Thing>> c;
  // The following line instantiates the static_assert failure,
  // but it is not listed in the error.
  const std::optional<std::vector<std::optional<Thing>>> &d = c;
}
```
* **Command and output**
```bash
$clang-14 symbol.cxx -std=c++20`
In file included from symbol.cxx:2:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/vector:66:
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_uninitialized.h:138:7: error: static_assert failed due to requirement 'is_constructible<std::optional<Thing>, const std::optional<Thing> &>::value' "result type must be constructible from value type of input range"
      static_assert(is_constructible<_ValueType2, decltype(*__first)>::value,
      ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_uninitialized.h:333:19: note: in instantiation of function template specialization 'std::uninitialized_copy<__gnu_cxx::__normal_iterator<const std::optional<Thing> *, std::vector<std::optional<Thing>>>, std::optional<Thing> *>' requested here
    { return std::uninitialized_copy(__first, __last, __result); }
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_vector.h:558:9: note: in instantiation of function template specialization 'std::__uninitialized_copy_a<__gnu_cxx::__normal_iterator<const std::optional<Thing> *, std::vector<std::optional<Thing>>>, std::optional<Thing> *, std::optional<Thing>>' requested here
          std::__uninitialized_copy_a(__x.begin(), __x.end(),
               ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/optional:225:8: note: in instantiation of member function 'std::vector<std::optional<Thing>>::vector' requested here
            : _M_value(std::forward<_Args>(__args)...)
              ^
In file included from symbol.cxx:2:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/vector:62:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_algo.h:62:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_tempbuf.h:60:
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_construct.h:109:38: error: call to implicitly-deleted copy constructor of 'std::optional<Thing>'
    { ::new(static_cast<void*>(__p)) _Tp(std::forward<_Args>(__args)...); }
                                     ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_uninitialized.h:92:8: note: in instantiation of function template specialization 'std::_Construct<std::optional<Thing>, const std::optional<Thing> &>' requested here
                std::_Construct(std::__addressof(*__cur), *__first);
                     ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_uninitialized.h:151:2: note: in instantiation of function template specialization 'std::__uninitialized_copy<false>::__uninit_copy<__gnu_cxx::__normal_iterator<const std::optional<Thing> *, std::vector<std::optional<Thing>>>, std::optional<Thing> *>' requested here
        __uninit_copy(__first, __last, __result);
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_uninitialized.h:333:19: note: in instantiation of function template specialization 'std::uninitialized_copy<__gnu_cxx::__normal_iterator<const std::optional<Thing> *, std::vector<std::optional<Thing>>>, std::optional<Thing> *>' requested here
    { return std::uninitialized_copy(__first, __last, __result); }
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_vector.h:558:9: note: in instantiation of function template specialization 'std::__uninitialized_copy_a<__gnu_cxx::__normal_iterator<const std::optional<Thing> *, std::vector<std::optional<Thing>>>, std::optional<Thing> *, std::optional<Thing>>' requested here
          std::__uninitialized_copy_a(__x.begin(), __x.end(),
               ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/optional:225:8: note: in instantiation of member function 'std::vector<std::optional<Thing>>::vector' requested here
            : _M_value(std::forward<_Args>(__args)...)
              ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/optional:665:7: note: copy constructor of 'optional<Thing>' is implicitly deleted because base class '_Enable_copy_move<is_copy_constructible_v<Thing>, __and_v<is_copy_constructible<Thing>, is_copy_assignable<Thing>>, is_move_constructible_v<Thing>, __and_v<is_move_constructible<Thing>, is_move_assignable<Thing>>, optional<Thing>>' has a deleted copy constructor
      private _Enable_copy_move<
      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/enable_special_members.h:159:15: note: '_Enable_copy_move' has been explicitly marked deleted here
    constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept  = delete;
              ^
2 errors generated.
```

> **The location where you obtained LLVM (if not from our Git repository).**
  *  **clang is installed from `apt`.**
```
$apt show clang-14 -a
Package: clang-14
Version: 1:14.0.5-1~kisak~f
Priority: optional
Section: devel
Source: llvm-toolchain-14
Maintainer: LLVM Packaging Team <pkg-llvm-team@lists.alioth.debian.org>
Installed-Size: 370 kB
Provides: c++-compiler, c-compiler, objc-compiler
Depends: libc6 (>= 2.14), libclang-cpp14 (>= 1:14.0.5), libgcc-s1 (>= 3.0), libllvm14, libstdc++6 (>= 5.2), libstdc++-9-dev, libgcc-9-dev, libobjc-9-dev, libclang-common-14-dev (= 1:14.0.5-1~kisak~f), llvm-14-linker-tools (= 1:14.0.5-1~kisak~f), libclang1-14 (= 1:14.0.5-1~kisak~f), libc6-dev, binutils
Recommends: llvm-14-dev, python3
Suggests: clang-14-doc
Download-Size: 126 kB
APT-Sources: http://ppa.launchpad.net/kisak/kisak-mesa/ubuntu focal/main amd64 Packages
Description: C, C++ and Objective-C compiler
 Clang project is a C, C++, Objective C and Objective C++ front-end
 based on the LLVM compiler. Its goal is to offer a replacement to the
 GNU Compiler Collection (GCC).
 .
 Clang implements all of the ISO C++ 1998, 11, 14 and 17 standards and also
 provides most of the support of C++20.

Package: clang-14
Version: 1:14.0.1-1~kisak1~f
Status: install ok installed
Priority: optional
Section: devel
Source: llvm-toolchain-14
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: LLVM Packaging Team <pkg-llvm-team@lists.alioth.debian.org>
Installed-Size: 370 kB
Provides: c++-compiler, c-compiler, objc-compiler
Depends: libc6 (>= 2.14), libclang-cpp14 (>= 1:14.0.1), libgcc-s1 (>= 3.0), libllvm14, libstdc++6 (>= 5.2), libstdc++-9-dev, libgcc-9-dev, libobjc-9-dev, libclang-common-14-dev (= 1:14.0.1-1~kisak1~f), llvm-14-linker-tools (= 1:14.0.1-1~kisak1~f), libclang1-14 (= 1:14.0.1-1~kisak1~f), libc6-dev, binutils
Recommends: llvm-14-dev, python3
Suggests: clang-14-doc
Homepage: https://www.llvm.org/
Download-Size: unknown
APT-Manual-Installed: yes
APT-Sources: /var/lib/dpkg/status
Description: C, C++ and Objective-C compiler
 Clang project is a C, C++, Objective C and Objective C++ front-end
 based on the LLVM compiler. Its goal is to offer a replacement to the
 GNU Compiler Collection (GCC).
 .
 Clang implements all of the ISO C++ 1998, 11, 14 and 17 standards and also
 provides most of the support of C++20.
 ```
* **clang version:**
```bash
$ clang-14 --version
Ubuntu clang version 14.0.1-1~kisak1~f
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
```
* OS: Ubuntu over WSL (Windows Subsystem for Linux) 
* **lsb_release -a**
```
$lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:        20.04
Codename:       focal
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWltz46gS_jXOCyWVJd-Shzw4dmY3VZmdrZPszKMKSdhmjYQOSHa8v_50A7o5zu2cndueuBzFQk3TNF9_NIJYpofLLxuWk1Lx9Zopnq8JJbqkJU8iqjVTJdnzcsNBYsPwQZ5SlRLBY0XVYRAuSCIoVCqgaqlt3WTrlYomjMiVqcVzrFdyUCpRDy3r5lhqBGxDqCyuSsJ2TB3Iigs2CD8InoOCEhrUoN6ZYbVzTXJZYlkF1UkiU0YG4bmiIKJQGVQDGWe-LlMwehBe4JP9hicbktEt0yjFHkCjVCnPqeLiQFK-WvGkEmCnJCmLqzUqJluep9p0CtuHzipGrK00k5U-rqgYTWuLV1zpkhQC6mH7aKHrAIppdIs09qA5OaMKlPGskFrzGP0QgOH-YLgcDOf2emP1mk7HTMg9qh1Mh4kEZ2NnB6M5fGWBPqdiMFo0ZTuWlFJ1SzpS9-Cr9WB0bb_Q7WlKBqMlSQajK1CPNvN8RwVPj4Y1ZgmFcSBGQT02iSwOxJikqqS0XVkQwBAYDyIrqdCP2JHaBFMNfBGzJyofWGkr5OCi2kGoDlrF0ZKk9m3tUWo0YV0t0b0Wbbrnzl_lHmHnxoYwpaQCXcx2o5AAbtR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