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

            Bug ID: 109049
           Summary: std::declval gives wrong result for cv void
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fsb4000 at yandex dot ru
  Target Milestone: ---

A. Jiang <d...@live.cn> found that:

Quote:

"The return type is... cursed for cv void.

It seems that decltype(std::declval<const void>) should be const void() (until
C++17) / const void() noexcept (since C++17) (same for volatile void and const
volatile void), but the cv-qualifiers are dropped"

Code example:

#include <utility>
#include <type_traits>

int main() {
    static_assert(std::is_same_v<decltype(std::declval<const void>), const void
() noexcept>);
    static_assert(std::is_same_v<decltype(std::declval<volatile void>),
volatile void () noexcept>);
}


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

I've created the same issue for libc++:
https://github.com/llvm/llvm-project/issues/61232

Reply via email to