public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/68891] must use a typedef to declare a conversion to 'double (&)[3]'
       [not found] <bug-68891-4@http.gcc.gnu.org/bugzilla/>
@ 2021-11-04  8:24 ` mathieu.malaterre at gmail dot com
  2021-11-04  9:44 ` redi at gcc dot gnu.org
  2024-01-08 16:23 ` mital at mitalashok dot co.uk
  2 siblings, 0 replies; 3+ messages in thread
From: mathieu.malaterre at gmail dot com @ 2021-11-04  8:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
Here is the output from clang++:

 error: cannot specify any part of a return type in the declaration of a
conversion function; use a typedef to declare a conversion to 'double (&)[3]'

% clang++ --version
Debian clang version 11.0.1-2

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

* [Bug c++/68891] must use a typedef to declare a conversion to 'double (&)[3]'
       [not found] <bug-68891-4@http.gcc.gnu.org/bugzilla/>
  2021-11-04  8:24 ` [Bug c++/68891] must use a typedef to declare a conversion to 'double (&)[3]' mathieu.malaterre at gmail dot com
@ 2021-11-04  9:44 ` redi at gcc dot gnu.org
  2024-01-08 16:23 ` mital at mitalashok dot co.uk
  2 siblings, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2021-11-04  9:44 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
           Keywords|                            |accepts-invalid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-11-04

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:

struct V
{
  (&operator double ())[3] {
    return v;
  }
  double v[3];
};

static void Print( const double (&)[3] )
{
}

int main()
{
  V v = {0,1,2};
  Print( v );
}

EDG accepts it too. MSVC says:

error C2586: incorrect user-defined conversion syntax: illegal indirections

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

* [Bug c++/68891] must use a typedef to declare a conversion to 'double (&)[3]'
       [not found] <bug-68891-4@http.gcc.gnu.org/bugzilla/>
  2021-11-04  8:24 ` [Bug c++/68891] must use a typedef to declare a conversion to 'double (&)[3]' mathieu.malaterre at gmail dot com
  2021-11-04  9:44 ` redi at gcc dot gnu.org
@ 2024-01-08 16:23 ` mital at mitalashok dot co.uk
  2 siblings, 0 replies; 3+ messages in thread
From: mital at mitalashok dot co.uk @ 2024-01-08 16:23 UTC (permalink / raw)
  To: gcc-bugs

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

Mital Ashok <mital at mitalashok dot co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mital at mitalashok dot co.uk

--- Comment #3 from Mital Ashok <mital at mitalashok dot co.uk> ---
This is also erroneously named with `operator double`:

assert(V{0,1,2}.operator double()[1] == 1.0);
using T = double;
assert(V{0,1,2}.operator T()[1] == 1.0);
using U = double(&)[3];
// 'struct V' has no member named 'operator U'
// V{0,1,2}.operator U();

And a similar thing happens with user defined conversions to function pointers
/ references

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

end of thread, other threads:[~2024-01-08 16:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-68891-4@http.gcc.gnu.org/bugzilla/>
2021-11-04  8:24 ` [Bug c++/68891] must use a typedef to declare a conversion to 'double (&)[3]' mathieu.malaterre at gmail dot com
2021-11-04  9:44 ` redi at gcc dot gnu.org
2024-01-08 16:23 ` mital at mitalashok dot co.uk

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