public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/29187]  New: Comparison with Pointer to Template Function Requires Explicit Cast
@ 2006-09-22 22:19 justin dot piper at gmail dot com
  2006-09-22 23:34 ` [Bug c++/29187] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: justin dot piper at gmail dot com @ 2006-09-22 22:19 UTC (permalink / raw)
  To: gcc-bugs

When I try to compile the code below, g++ reports "error: assuming cast to type
'bool (*)(evaluator&)' from overloaded function" on the line indicated. I have
isolated the comparison to the pointer to the template function "stop" as the
source of the problem. Is this the correct behavior?

   #include <iostream>

   struct evaluator { bool (*eval)(evaluator&); };

   template <typename T>
   bool stop(T &e) { return true; }

   bool eval(evaluator &e) { return true; }

   int main() {
      typedef bool (*evalf)(evaluator&);
      struct evaluator e = { stop<evaluator> };

      // error: assuming cast to type 'bool (*)(evaluator&)' from
      // overloaded function
      std::cout << (e.eval == stop<evaluator>) << '\n';

      // ok--eval is not templated
      std::cout << (e.eval == eval) << '\n';

      // ok--explicitly cast to correct type
      std::cout << (e.eval == static_cast<evalf>(stop<evaluator>)) << '\n';

      return 0;
   }

I compiled this using the MinGW port of g++ 3.4.2 on W2kSP4. I unfortunately do
not have easy access to g++ 4.1.1, however Kai-Uwe Bux reports the same result
from that version via comp.lang.c++ (discussion archived at
http://groups.google.com/group/comp.lang.c++/browse_frm/thread/b25fee316ec891b6).


-- 
           Summary: Comparison with Pointer to Template Function Requires
                    Explicit Cast
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: justin dot piper at gmail dot com


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


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

* [Bug c++/29187] Comparison with Pointer to Template Function Requires Explicit Cast
  2006-09-22 22:19 [Bug c++/29187] New: Comparison with Pointer to Template Function Requires Explicit Cast justin dot piper at gmail dot com
@ 2006-09-22 23:34 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-22 23:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-09-22 23:33 -------
There was a defect report about this problem to the C++ standard.

Anyways this is a dup of bug 11407.  The C++ standard committee decided this
was valid thing to do.

*** This bug has been marked as a duplicate of 11407 ***


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2006-09-22 23:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-22 22:19 [Bug c++/29187] New: Comparison with Pointer to Template Function Requires Explicit Cast justin dot piper at gmail dot com
2006-09-22 23:34 ` [Bug c++/29187] " pinskia at gcc dot gnu dot 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).