c++/1040: accepts illegal code: cv-quals on member function pointers

bh@techhouse.brown.edu bh@techhouse.brown.edu
Mon Dec 11 11:06:00 GMT 2000


>Number:         1040
>Category:       c++
>Synopsis:       accepts illegal code: cv-quals on member function pointers
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 11 11:06:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     bh@techhouse.brown.edu
>Release:        2.95.2
>Organization:
>Environment:

>Description:
I gather, from the discussion I started on clc++m , that 
the code in how-to-repeat is illegal; 2.95.2 accepts it.

The problem is that the type:
    bool (bar::*)(const bar&) const;
should not be implicitely cast to:
    bool (bar::*)(const bar&);
for reasons that aren't entirely clear to me.
>How-To-Repeat:
template <class T> struct A {
     bool (T::*compare)(const T&);
     A() { compare = &T::operator<; }
};
  
struct bar { bool operator<(const bar&) const; };
 
int main() {
    A<bar> abar;
    return 0;
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the Gcc-bugs mailing list