[Bug c++/96877] New: Erroneous warning when default initializing function pointer types defined using std::declval

insertinterestingnamehere at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Sep 1 02:07:17 GMT 2020


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

            Bug ID: 96877
           Summary: Erroneous warning when default initializing function
                    pointer types defined using std::declval
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: insertinterestingnamehere at gmail dot com
  Target Milestone: ---

When compiling the following with -Wextra (C++11 and later, all recent version
of gcc) the compiler emits an erroneous warning about binding a temporary in a
constructor. Note: this works fine if function_type is declared as a plain
typedef instead of using decltype and std::declval. See
https://godbolt.org/z/sjKdP5.



#include <utility>

using function_type = decltype(std::declval<void (*)(void*) noexcept>());

struct S {
  function_type fptr = nullptr;
};

int main() {
    S thing;
}


More information about the Gcc-bugs mailing list