public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53660] New: function pointer conversion function template with nested-name-specifier ignored
@ 2012-06-13 19:30 potswa at mac dot com
  2021-08-04 18:36 ` [Bug c++/53660] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: potswa at mac dot com @ 2012-06-13 19:30 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53660

             Bug #: 53660
           Summary: function pointer conversion function template with
                    nested-name-specifier ignored
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: potswa@mac.com


template< bool >
struct enable_if { typedef void (*t)(); };

struct c {
    template< bool t = true >
    operator typename enable_if< t >::t () { return []{}; }
};

int main() {
    c()(); // error: no match for call to ‘(c) ()’
}

http://stackoverflow.com/questions/11018810

In C++03 it seems that it was impossible to define a conversion function
template that would render its class Callable. Yet there is a function
add_template_conv_candidate (cp/call.c) which seems to be used only for this
purpose. It was added back in 1997 and it's not clear that it's been tested in
a while. Now with default function template arguments the above construct is
possible, and it should be called but isn't.

The problem is that the test for function pointer type (etc.) is applied before
instantiation in build_op_call_1. The test probably belongs in
add_conv_candidate.


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

* [Bug c++/53660] function pointer conversion function template with nested-name-specifier ignored
  2012-06-13 19:30 [Bug c++/53660] New: function pointer conversion function template with nested-name-specifier ignored potswa at mac dot com
@ 2021-08-04 18:36 ` pinskia at gcc dot gnu.org
  2021-08-04 22:28 ` potswa at mac dot com
  2021-08-06 11:38 ` potswa at mac dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-04 18:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I don't think this is a bug.

GCC, ICC and clang all reject it the same way.
MSV rejects it with:
<source>(10): error C2783: 'c::operator enable_if<__formal>::t(void)': could
not deduce template argument for 't'

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

* [Bug c++/53660] function pointer conversion function template with nested-name-specifier ignored
  2012-06-13 19:30 [Bug c++/53660] New: function pointer conversion function template with nested-name-specifier ignored potswa at mac dot com
  2021-08-04 18:36 ` [Bug c++/53660] " pinskia at gcc dot gnu.org
@ 2021-08-04 22:28 ` potswa at mac dot com
  2021-08-06 11:38 ` potswa at mac dot com
  2 siblings, 0 replies; 4+ messages in thread
From: potswa at mac dot com @ 2021-08-04 22:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from David Krauss <potswa at mac dot com> ---
(In reply to Andrew Pinski from comment #1)
> I don't think this is a bug.

Right, the behavior looks correct.

As for a nested-name-specifier working in this context, it works if it's not
dependent. As for the declaration being a function template, it works as long
as the conversion-type-id is not dependent.

Oddly, a dependent conversion-type-id *is* allowed when the function is not
templated.

Anyway, the standard says to inspect the conversion function declarations and
find the ones referring to function (-pointer, -reference) types. That doesn't
admit application of template default arguments, as implicit or explicit
conversion does.

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

* [Bug c++/53660] function pointer conversion function template with nested-name-specifier ignored
  2012-06-13 19:30 [Bug c++/53660] New: function pointer conversion function template with nested-name-specifier ignored potswa at mac dot com
  2021-08-04 18:36 ` [Bug c++/53660] " pinskia at gcc dot gnu.org
  2021-08-04 22:28 ` potswa at mac dot com
@ 2021-08-06 11:38 ` potswa at mac dot com
  2 siblings, 0 replies; 4+ messages in thread
From: potswa at mac dot com @ 2021-08-06 11:38 UTC (permalink / raw)
  To: gcc-bugs

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

David Krauss <potswa at mac dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #3 from David Krauss <potswa at mac dot com> ---
(The standardese mentions "for each … where the conversion-type-id denotes a
type" which excludes the case of being a dependent type.)

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

end of thread, other threads:[~2021-08-06 11:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-13 19:30 [Bug c++/53660] New: function pointer conversion function template with nested-name-specifier ignored potswa at mac dot com
2021-08-04 18:36 ` [Bug c++/53660] " pinskia at gcc dot gnu.org
2021-08-04 22:28 ` potswa at mac dot com
2021-08-06 11:38 ` potswa at mac 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).