https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99374
Bug ID: 99374 Summary: C++17/20 mode fails to recognise pointer-to-member functions of incomplete types in conditional expression Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: cjdb.ns at gmail dot com Target Milestone: --- Created attachment 50296 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50296&action=edit Failure with -std=c++17 GCC seems to be unable to handle pointer-to-member functions of incomplete types in conditional expressions. The following works on both Clang and MSVC, and some invocations of GCC. ``` struct S; using F1 = int (S::*)(); using F2 = int (S::*)() noexcept; auto v = true ? F1() : F2(); auto w = true ? F2() : F1(); ``` This appears to work if `-std=c++14`, but not `-std=c++17` or `-std=c++20` for GCC versions >= 7. GCC < 7 doesn't have a problem compiling even in C++17 mode. # Versions * All GCC releases from 7.1.0 through trunk. # System type * Ubuntu 18.04 (checked GCC 10.1) * Ubuntu 20.04 on WSL2 (checked GCC 10.2) * Debian (checked GCC 10.2.1) * Compiler Explorer (checked all other reported versions). # Options given to GCC `g++ -save-temps fail-17.cpp -c -std=c++17` # Diagnostic ``` fail-17.cpp:5:27: error: could not convert ‘((int (S::*)() noexcept)0)’ from ‘int (S::*)() noexcept’ to ‘int (S::*)()’ 5 | auto v = true ? F1() : F2(); | ^ | | | int (S::*)() noexcept fail-17.cpp:6:27: error: could not convert ‘((int (S::*)() noexcept)0)’ from ‘int (S::*)() noexcept’ to ‘int (S::*)()’ 6 | auto w = true ? F2() : F1(); | ^ | | | int (S::*)() noexcept ```