public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98388] New: Throwing move-only parameter results in hard error in SFINAE context
@ 2020-12-19  5:58 ensadc at mailnesia dot com
  2021-02-04 11:04 ` [Bug c++/98388] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ensadc at mailnesia dot com @ 2020-12-19  5:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98388
           Summary: Throwing move-only parameter results in hard error in
                    SFINAE context
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ensadc at mailnesia dot com
  Target Milestone: ---

https://godbolt.org/z/xn8fYz

====
struct moveonly {
    moveonly() = default;
    moveonly(moveonly&&) = default;
};

template<class T>
constexpr auto is_throwable(T t) -> decltype(throw t, true) {
    return true;
}
template<class T>
constexpr bool is_throwable(...) { return false; }

constexpr bool b = is_throwable<moveonly>(moveonly{});

====
<source>: In substitution of 'template<class T> constexpr decltype
((<throw-expression>, true)) is_throwable(T) [with T = moveonly]':
<source>:13:43:   required from here
<source>:7:46: error: use of deleted function 'constexpr
moveonly::moveonly(const moveonly&)'
    7 | constexpr auto is_throwable(T t) -> decltype(throw t, true) {
      |                                              ^~~~~~~
<source>:1:8: note: 'constexpr moveonly::moveonly(const moveonly&)' is
implicitly declared as deleted because 'moveonly' declares a move constructor
or move assignment operator
    1 | struct moveonly {
      |        ^~~~~~~~
<source>:7:52: note:   in thrown expression
    7 | constexpr auto is_throwable(T t) -> decltype(throw t, true) {
      |                                                    ^
====

I'm not sure what the value of `b` should be, but I believe that it should not
be a hard error. (Clang and MSVC initialize `b` to `true`.)

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

end of thread, other threads:[~2024-02-16 17:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-19  5:58 [Bug c++/98388] New: Throwing move-only parameter results in hard error in SFINAE context ensadc at mailnesia dot com
2021-02-04 11:04 ` [Bug c++/98388] " redi at gcc dot gnu.org
2024-02-07 15:34 ` mpolacek at gcc dot gnu.org
2024-02-09 21:38 ` cvs-commit at gcc dot gnu.org
2024-02-09 21:43 ` mpolacek at gcc dot gnu.org
2024-02-16 17:13 ` 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).