public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33990]  New: bug in lookup of member template conversion operator for pointer to member functions
@ 2007-11-03 22:00 sutambe at yahoo dot com
  2007-11-05  0:05 ` [Bug c++/33990] " sutambe at yahoo dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: sutambe at yahoo dot com @ 2007-11-03 22:00 UTC (permalink / raw)
  To: gcc-bugs

In the code snippet below, the comparison (nullptr == pmf) in main should
compile but on gcc it fails to compile. Compiler fails to find appropriate
conversion operator and gives error saying:
error: no match for operator== in nullptr == pmf

class nullptr_t 
{
  public:
      template<class T>
      operator T*() const // convertible to any type of null non-member
pointer...
    { return 0; }

    template<class C, class T>
    operator T C::*() const   // or any type of null member pointer...
    { return 0; }
} nullptr = {};
struct C
{
  void func ();
};
int main(void)
{
  char * ch = nullptr;
  void (C::*pmf)() = nullptr; 
  if (nullptr == ch) {}       // Compiles successfully
  if (nullptr == pmf) {}      // Should compile but does not compile on gcc
4.1.1
}


-- 
           Summary: bug in lookup of member template conversion operator for
                    pointer to member functions
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sutambe at yahoo dot com
  GCC host triplet: Linux i686


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


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

* [Bug c++/33990] bug in lookup of member template conversion operator for pointer to member functions
  2007-11-03 22:00 [Bug c++/33990] New: bug in lookup of member template conversion operator for pointer to member functions sutambe at yahoo dot com
@ 2007-11-05  0:05 ` sutambe at yahoo dot com
  2007-11-15  4:34 ` bangerth at dealii dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: sutambe at yahoo dot com @ 2007-11-05  0:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from sutambe at yahoo dot com  2007-11-05 00:05 -------
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic
--host=i386-redhat-linux
Thread model: posix
gcc version 4.1.1 20070105 (Red Hat 4.1.1-51)


-- 


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


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

* [Bug c++/33990] bug in lookup of member template conversion operator for pointer to member functions
  2007-11-03 22:00 [Bug c++/33990] New: bug in lookup of member template conversion operator for pointer to member functions sutambe at yahoo dot com
  2007-11-05  0:05 ` [Bug c++/33990] " sutambe at yahoo dot com
@ 2007-11-15  4:34 ` bangerth at dealii dot org
  2009-10-04 15:33 ` ylalym at gmail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2007-11-15  4:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from bangerth at dealii dot org  2007-11-15 04:33 -------
Confirmed with 2.95 and 4.2.1.
W.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at dealii dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |rejects-valid
      Known to fail|                            |2.95 4.2.1
   Last reconfirmed|0000-00-00 00:00:00         |2007-11-15 04:33:52
               date|                            |


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


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

* [Bug c++/33990] bug in lookup of member template conversion operator for pointer to member functions
  2007-11-03 22:00 [Bug c++/33990] New: bug in lookup of member template conversion operator for pointer to member functions sutambe at yahoo dot com
  2007-11-05  0:05 ` [Bug c++/33990] " sutambe at yahoo dot com
  2007-11-15  4:34 ` bangerth at dealii dot org
@ 2009-10-04 15:33 ` ylalym at gmail dot com
  2010-06-27  9:45 ` pluto at agmk dot net
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ylalym at gmail dot com @ 2009-10-04 15:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ylalym at gmail dot com  2009-10-04 15:33 -------
(In reply to comment #0)
There is a makeshift.

File a.cpp
#include <stdio.h>

const class nullptr_t
{
public:
  template<class T> operator T*() const { return 0; }
  template<class C, class T> operator T C::*() const { return 0; }

  // void (C::*pmf)() = nullptr;        // Ok
  // if (nullptr == pmf) {}             // Ok
  template<class C, class T> bool operator == (C (T::*p)()) const
    { return  p == 0; }

  private:
    void operator&() const;

    // const int n = 0;
    // if (nullptr == n) {}             // Error
    bool operator == (long) const;
}
nullptr = {};

struct C
{
  void func();
};

int main(void)
{
  void (C::*pmf)() = nullptr;
  if (nullptr == pmf) {printf("Ok\n");}

  // If there are sentences - send !!!!!!!!
  // if (pmf == nullptr) {printf("Ok\n");} // Error
}

> g++ a.cpp
> ./a.out
Ok
>


-- 

ylalym at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ylalym at gmail dot com


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


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

* [Bug c++/33990] bug in lookup of member template conversion operator for pointer to member functions
  2007-11-03 22:00 [Bug c++/33990] New: bug in lookup of member template conversion operator for pointer to member functions sutambe at yahoo dot com
                   ` (2 preceding siblings ...)
  2009-10-04 15:33 ` ylalym at gmail dot com
@ 2010-06-27  9:45 ` pluto at agmk dot net
  2010-06-27 10:26 ` redi at gcc dot gnu dot org
  2010-06-28  9:48 ` pluto at agmk dot net
  5 siblings, 0 replies; 7+ messages in thread
From: pluto at agmk dot net @ 2010-06-27  9:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pluto at agmk dot net  2010-06-27 09:45 -------
current 4.5 rejects all conversions:

$ cat t.cpp
const                        // this is a const object...
class {
public:
  template<class T>          // convertible to any type
    operator T*() const      // of null non-member
    { return 0; }            // pointer...
  template<class C, class T> // or any type of null
    operator T C::*() const  // member pointer...
    { return 0; }
private:
  void operator&() const;    // whose address can't be taken
} nullptr = {};              // and whose name is nullptr

extern void* p;
struct A
{
  void foo();
};
extern void (A::*pmf)();
int main()
{
  return ( ( p != nullptr ) && ( pmf != nullptr ) );
}


$ g++ t.cpp -std=c++0x -c
t.cpp: In function 'int main()':
t.cpp:22:19: error: no match for 'operator!=' in 'p != nullptr'
t.cpp:22:41: error: no match for 'operator!=' in 'pmf != nullptr'


-- 

pluto at agmk dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pluto at agmk dot net


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


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

* [Bug c++/33990] bug in lookup of member template conversion operator for pointer to member functions
  2007-11-03 22:00 [Bug c++/33990] New: bug in lookup of member template conversion operator for pointer to member functions sutambe at yahoo dot com
                   ` (3 preceding siblings ...)
  2010-06-27  9:45 ` pluto at agmk dot net
@ 2010-06-27 10:26 ` redi at gcc dot gnu dot org
  2010-06-28  9:48 ` pluto at agmk dot net
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu dot org @ 2010-06-27 10:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from redi at gcc dot gnu dot org  2010-06-27 10:26 -------
N.B. nullptr is a keyword in c++0x, and proper nullptr support has been added
to 4.6 anyway, but those covnersions should still work


-- 


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


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

* [Bug c++/33990] bug in lookup of member template conversion operator for pointer to member functions
  2007-11-03 22:00 [Bug c++/33990] New: bug in lookup of member template conversion operator for pointer to member functions sutambe at yahoo dot com
                   ` (4 preceding siblings ...)
  2010-06-27 10:26 ` redi at gcc dot gnu dot org
@ 2010-06-28  9:48 ` pluto at agmk dot net
  5 siblings, 0 replies; 7+ messages in thread
From: pluto at agmk dot net @ 2010-06-28  9:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pluto at agmk dot net  2010-06-28 09:47 -------
(In reply to comment #5)
> N.B. nullptr is a keyword in c++0x, and proper nullptr support has been added
> to 4.6 anyway, but those covnersions should still work

gcc <= 4.4 rejects only operator!=(pmf,nullptr):

$ g++44 t.cpp -Wall -c -std=c++0x
t.cpp: In function 'int main()':
t.cpp:21: error: no match for 'operator!=' in 'pmf != nullptr'

gcc >= 4.5 rejects also operator!=(p,nullptr):

$ g++45 t.cpp -Wall -c -std=c++0x
t.cpp: In function 'int main()':
t.cpp:21:19: error: no match for 'operator!=' in 'p != nullptr'
t.cpp:21:41: error: no match for 'operator!=' in 'pmf != nullptr'


-- 


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


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

end of thread, other threads:[~2010-06-28  9:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-03 22:00 [Bug c++/33990] New: bug in lookup of member template conversion operator for pointer to member functions sutambe at yahoo dot com
2007-11-05  0:05 ` [Bug c++/33990] " sutambe at yahoo dot com
2007-11-15  4:34 ` bangerth at dealii dot org
2009-10-04 15:33 ` ylalym at gmail dot com
2010-06-27  9:45 ` pluto at agmk dot net
2010-06-27 10:26 ` redi at gcc dot gnu dot org
2010-06-28  9:48 ` pluto at agmk dot net

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