public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99374] New: C++17/20 mode fails to recognise pointer-to-member functions of incomplete types in conditional expression
@ 2021-03-03 23:57 cjdb.ns at gmail dot com
  2021-03-04 10:38 ` [Bug c++/99374] " redi at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: cjdb.ns at gmail dot com @ 2021-03-03 23:57 UTC (permalink / raw)
  To: gcc-bugs

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
```

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-04-09 22:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03 23:57 [Bug c++/99374] New: C++17/20 mode fails to recognise pointer-to-member functions of incomplete types in conditional expression cjdb.ns at gmail dot com
2021-03-04 10:38 ` [Bug c++/99374] " redi at gcc dot gnu.org
2021-03-04 10:41 ` redi at gcc dot gnu.org
2021-03-04 10:44 ` redi at gcc dot gnu.org
2021-03-04 18:42 ` [Bug c++/99374] [8/9/10/11 Regression] " mpolacek at gcc dot gnu.org
2021-03-04 18:43 ` mpolacek at gcc dot gnu.org
2021-03-05 23:08 ` cvs-commit at gcc dot gnu.org
2021-03-05 23:09 ` [Bug c++/99374] [8/9/10 " mpolacek at gcc dot gnu.org
2021-04-09 22:36 ` cvs-commit at gcc dot gnu.org
2021-04-09 22:37 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).