public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113219] New: Overloaded ref-qualified conversion operator triggers bogus -Wconversion
@ 2024-01-03 16:38 m.cencora at gmail dot com
  2024-01-03 21:58 ` [Bug c++/113219] " pinskia at gcc dot gnu.org
  2024-01-04  8:17 ` m.cencora at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: m.cencora at gmail dot com @ 2024-01-03 16:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113219
           Summary: Overloaded ref-qualified conversion operator triggers
                    bogus -Wconversion
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m.cencora at gmail dot com
  Target Milestone: ---

Following code when compiled on any gcc version (checked all available on
godbolt since gcc-7) triggers conversion warnings.
I consider it bogus because it tells user that it has chosen a better overload
(which is good thing, right?).
Clang doesn't print any related warning even with -Weverything

g++ -std=c++17 -Wconversion

template <typename T>
struct wrapper
{
    operator T() const&;

    operator T&&() &&;
};

wrapper<int> createInt();

int test()
{
    return createInt();
}

Output is:
<source>:13:21: warning: choosing 'wrapper<T>::operator T&&() && [with T =
int]' over 'wrapper<T>::operator T() const & [with T = int]' [-Wconversion]
   13 |     return createInt();
      |            ~~~~~~~~~^~
<source>:13:21: warning:   for conversion from 'wrapper<int>' to 'int'
[-Wconversion]
<source>:13:21: note:   because conversion sequence for the argument is better

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

end of thread, other threads:[~2024-01-04  8:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-03 16:38 [Bug c++/113219] New: Overloaded ref-qualified conversion operator triggers bogus -Wconversion m.cencora at gmail dot com
2024-01-03 21:58 ` [Bug c++/113219] " pinskia at gcc dot gnu.org
2024-01-04  8:17 ` m.cencora at gmail dot com

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).