https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109061

            Bug ID: 109061
           Summary: GCC try to eagerly instantiate more than needed
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fsb4000 at yandex dot ru
  Target Milestone: ---

While submitting a libc++ patch about adding `static_assert` to `std::declval`:
https://reviews.llvm.org/D145376

I got an opinion from a compiler frontend dev that the patch is incorrect
because it broke the code:


template <class T, class U, class = U[std::declval<T>()]>
constexpr bool xxx(int) { return true; }

template <class T, class U>
constexpr bool xxx(long) { return false; }

constexpr bool y = xxx<long long, int>(0);


I believe that my patch is correct and libstdc++ and MSVC STL has the similar
implementations with `static_assert`.

I checked GCC 12.2.0 behaviour and found that it also doesn't work with that
example:

https://gcc.godbolt.org/z/MssGMMqsd

And because I believe that the library implementations are correct I create a
bug against C++ and not libstdc++

Reply via email to