public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/24243]  New: [4.0 regression] lookup fails to match to function call, const-sensitive
@ 2005-10-06 19:20 fang at csl dot cornell dot edu
  2005-10-06 19:22 ` [Bug c++/24243] " fang at csl dot cornell dot edu
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: fang at csl dot cornell dot edu @ 2005-10-06 19:20 UTC (permalink / raw)
  To: gcc-bugs

command: g++-4 -v -save-temps -c lookup-bug.cc

keywords: rejects-valid

expecting: (success)

program output:
Using built-in specs.
Target: powerpc-apple-darwin7
Configured with: ../configure --prefix=/sw --prefix=/sw/lib/gcc4
--enable-languages=c,c++,f95,objc,java --infodir=/share/info --with-gmp=/sw
--with-included-gettext --host=powerpc-apple-darwin7
--with-as=/sw/lib/odcctools/bin/as --with-ld=/sw/lib/odcctools/bin/ld
Thread model: posix
gcc version 4.0.2
 /sw/lib/gcc4/libexec/gcc/powerpc-apple-darwin7/4.0.2/cc1plus -E -quiet -v
-D__DYNAMIC__ -D__APPLE_CC__=1 lookup-bug.cc -fPIC -fpch-preprocess -o
lookup-bug.ii
ignoring nonexistent directory
"/sw/lib/gcc4/lib/gcc/powerpc-apple-darwin7/4.0.2/../../../../powerpc-apple-darwin7/include"
#include "..." search starts here:
#include <...> search starts here:
 /sw/lib/gcc4/lib/gcc/powerpc-apple-darwin7/4.0.2/../../../../include/c++/4.0.2

/sw/lib/gcc4/lib/gcc/powerpc-apple-darwin7/4.0.2/../../../../include/c++/4.0.2/powerpc-apple-darwin7

/sw/lib/gcc4/lib/gcc/powerpc-apple-darwin7/4.0.2/../../../../include/c++/4.0.2/backward
 /usr/local/include
 /sw/lib/gcc4/include
 /sw/lib/gcc4/lib/gcc/powerpc-apple-darwin7/4.0.2/include
 /usr/include
 /System/Library/Frameworks
 /Library/Frameworks
End of search list.
 /sw/lib/gcc4/libexec/gcc/powerpc-apple-darwin7/4.0.2/cc1plus -fpreprocessed
lookup-bug.ii -fPIC -quiet -dumpbase lookup-bug.cc -auxbase lookup-bug -version
-o lookup-bug.s
GNU C++ version 4.0.2 (powerpc-apple-darwin7)
        compiled by GNU C version 3.3 20030304 (Apple Computer, Inc. build
1640).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
lookup-bug.cc: In member function 'std::ostream&
foo::name_space::dump(std::ostream&) const':
lookup-bug.cc:249: error: no matching function for call to
'mem_fun(std::ostream& (foo::instance_collection_base::*)(std::ostream&)const,
const util::memory::never_ptr<const foo::instance_collection_base>&)'

known to work: gcc-4.0.1 (built likewise)

remarks:
Note that this is not std::mem_fun, but rather, a custom extension for
pointer-classes, defined in namespace util.
In the attached .ii, changing the static member declaration:
    static const never_ptr<const instance_collection_base> null;
to
    static const never_ptr<instance_collection_base> null;
is sufficient to compile successfully.


-- 
           Summary: [4.0 regression] lookup fails to match to function call,
                    const-sensitive
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fang at csl dot cornell dot edu


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


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

* [Bug c++/24243] [4.0 regression] lookup fails to match to function call, const-sensitive
  2005-10-06 19:20 [Bug c++/24243] New: [4.0 regression] lookup fails to match to function call, const-sensitive fang at csl dot cornell dot edu
@ 2005-10-06 19:22 ` fang at csl dot cornell dot edu
  2005-10-06 19:48 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fang at csl dot cornell dot edu @ 2005-10-06 19:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from fang at csl dot cornell dot edu  2005-10-06 19:22 -------
Created an attachment (id=9912)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9912&action=view)
test case triggering bug


-- 


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


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

* [Bug c++/24243] [4.0 regression] lookup fails to match to function call, const-sensitive
  2005-10-06 19:20 [Bug c++/24243] New: [4.0 regression] lookup fails to match to function call, const-sensitive fang at csl dot cornell dot edu
  2005-10-06 19:22 ` [Bug c++/24243] " fang at csl dot cornell dot edu
@ 2005-10-06 19:48 ` pinskia at gcc dot gnu dot org
  2005-10-06 20:30 ` fang at csl dot cornell dot edu
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-06 19:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2005-10-06 19:48 -------
Here is the reduced testcase:
template <class R, template <class> class P, class T, class A>
 inline int  mem_fun(R (T::*f)(A), const P<T>& null) {}

template <class T> class never_ptr {};

struct instance_collection_base {
  int&  pair_dump(int&) const;
  static const never_ptr<const instance_collection_base> null;
};

int& dump(int& o) {
mem_fun(&instance_collection_base::pair_dump,  
instance_collection_base::null);
}

But I think this is invalid as "const instance_collection_base" is not the same
as instance_collection_base.  so T cannot be matched to "const
instance_collection_base" as it was before 4.1.0/4.0.2.

ICC and Comeau rejects the same code too for the same reason.


-- 


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


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

* [Bug c++/24243] [4.0 regression] lookup fails to match to function call, const-sensitive
  2005-10-06 19:20 [Bug c++/24243] New: [4.0 regression] lookup fails to match to function call, const-sensitive fang at csl dot cornell dot edu
  2005-10-06 19:22 ` [Bug c++/24243] " fang at csl dot cornell dot edu
  2005-10-06 19:48 ` pinskia at gcc dot gnu dot org
@ 2005-10-06 20:30 ` fang at csl dot cornell dot edu
  2005-10-06 21:28 ` fang at csl dot cornell dot edu
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fang at csl dot cornell dot edu @ 2005-10-06 20:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from fang at csl dot cornell dot edu  2005-10-06 20:30 -------
Subject: Re:  [4.0 regression] lookup fails to match to function
 call, const-sensitive

> ------- Comment #2 from pinskia at gcc dot gnu dot org  2005-10-06 19:48 -------
> Here is the reduced testcase:
> template <class R, template <class> class P, class T, class A>
>  inline int  mem_fun(R (T::*f)(A), const P<T>& null) {}
>
> template <class T> class never_ptr {};
>
> struct instance_collection_base {
>   int&  pair_dump(int&) const;
>   static const never_ptr<const instance_collection_base> null;
> };
>
> int& dump(int& o) {
> mem_fun(&instance_collection_base::pair_dump,
> instance_collection_base::null);
> }
>
> But I think this is invalid as "const instance_collection_base" is not
> the same as instance_collection_base.  so T cannot be matched to
> "const instance_collection_base" as it was before 4.1.0/4.0.2.
>
> ICC and Comeau rejects the same code too for the same reason.

True, const T != T, but shouldn't const-volatile qualifiers be disregarded
when trying to match member functions of T?

Perhaps irrelevant, but in the context of my test-case I wanted to
be precise about member-function constness.


-- 


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


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

* [Bug c++/24243] [4.0 regression] lookup fails to match to function call, const-sensitive
  2005-10-06 19:20 [Bug c++/24243] New: [4.0 regression] lookup fails to match to function call, const-sensitive fang at csl dot cornell dot edu
                   ` (2 preceding siblings ...)
  2005-10-06 20:30 ` fang at csl dot cornell dot edu
@ 2005-10-06 21:28 ` fang at csl dot cornell dot edu
  2005-10-06 21:41 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fang at csl dot cornell dot edu @ 2005-10-06 21:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from fang at csl dot cornell dot edu  2005-10-06 21:28 -------
Subject: Re:  [4.0 regression] lookup fails to match to function
 call, const-sensitive

Something else puzzling to me, that I noticed from your reduction:
Why is the compiler always matching the non-const version of mem_fun, when
the member-function I'm passing in (pair_dump) is const? Isn't the const a
closer match?  In fact, if I remove the non-const mem_fun() definition,
then I get "no match found" from g++-3.3 to 4.0 -- doesn't even accept the
const version.  I've seen some old PRs on this matter, but don't recall
what their resolution was.

> mem_fun(&instance_collection_base::pair_dump,
> instance_collection_base::null);

// prefers this:
template <class R, template <class> class P, class T, class A>
inline
mem_fun1_p_t<R, P, T, A>
mem_fun(R (T::*f)(A), const P<T>& null) {
        return mem_fun1_p_t<R, P, T, A>(f);
}

// over this:
template <class R, template <class> class P, class T, class A>
inline
const_mem_fun1_p_t<R, P, T, A>
mem_fun(R (T::*f)(A) const, const P<T>& null) {
        return const_mem_fun1_p_t<R, P, T, A>(f);
}


-- 


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


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

* [Bug c++/24243] [4.0 regression] lookup fails to match to function call, const-sensitive
  2005-10-06 19:20 [Bug c++/24243] New: [4.0 regression] lookup fails to match to function call, const-sensitive fang at csl dot cornell dot edu
                   ` (3 preceding siblings ...)
  2005-10-06 21:28 ` fang at csl dot cornell dot edu
@ 2005-10-06 21:41 ` rguenth at gcc dot gnu dot org
  2005-10-06 21:47 ` fang at csl dot cornell dot edu
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-10-06 21:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2005-10-06 21:41 -------
I have seen this issue one time and the solution is to cast the argument to
memfun to the appropriate type - f.i. the const member function, or to specify
the template parameters to memfun.  In case you have both const and non-const
member functions you'll have an ambiguous match otherwise.

This really is invalid.


-- 


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


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

* [Bug c++/24243] [4.0 regression] lookup fails to match to function call, const-sensitive
  2005-10-06 19:20 [Bug c++/24243] New: [4.0 regression] lookup fails to match to function call, const-sensitive fang at csl dot cornell dot edu
                   ` (4 preceding siblings ...)
  2005-10-06 21:41 ` rguenth at gcc dot gnu dot org
@ 2005-10-06 21:47 ` fang at csl dot cornell dot edu
  2005-10-06 23:38 ` fang at csl dot cornell dot edu
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fang at csl dot cornell dot edu @ 2005-10-06 21:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from fang at csl dot cornell dot edu  2005-10-06 21:47 -------
I now second your opinions that this is invalid.
Upon closer examination, what I *should've* written to make this code valid is
the following:

template <class R, template <class> class P, class T, class A>
inline
const_mem_fun1_p_t<R, P, T, A>
mem_fun(R (T::*f)(A) const, const P<const T>& null) {
        return const_mem_fun1_p_t<R, P, T, A>(f);
}

To be more correct, I changed "const P<T>" to "const P<const T>" in the
function parameter list.
Now gcc-3.3 to 4.0.x find the right match and accept it.  
(So really, the previous versions 'accepts-invalid.')

Thanks for being patient with me on this.  


-- 


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


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

* [Bug c++/24243] [4.0 regression] lookup fails to match to function call, const-sensitive
  2005-10-06 19:20 [Bug c++/24243] New: [4.0 regression] lookup fails to match to function call, const-sensitive fang at csl dot cornell dot edu
                   ` (5 preceding siblings ...)
  2005-10-06 21:47 ` fang at csl dot cornell dot edu
@ 2005-10-06 23:38 ` fang at csl dot cornell dot edu
  2006-03-11 22:11 ` fang at csl dot cornell dot edu
  2006-06-04 19:41 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: fang at csl dot cornell dot edu @ 2005-10-06 23:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from fang at csl dot cornell dot edu  2005-10-06 23:38 -------
Created an attachment (id=9913)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9913&action=view)
corrected header file

Just as a follow-up, here's what the new valid header file looks like, with all
the various mem_fun definitions corrected in the const cases.  (Perhaps this
might be useful for reference in future test cases?)


-- 


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


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

* [Bug c++/24243] [4.0 regression] lookup fails to match to function call, const-sensitive
  2005-10-06 19:20 [Bug c++/24243] New: [4.0 regression] lookup fails to match to function call, const-sensitive fang at csl dot cornell dot edu
                   ` (6 preceding siblings ...)
  2005-10-06 23:38 ` fang at csl dot cornell dot edu
@ 2006-03-11 22:11 ` fang at csl dot cornell dot edu
  2006-06-04 19:41 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: fang at csl dot cornell dot edu @ 2006-03-11 22:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from fang at csl dot cornell dot edu  2006-03-11 22:10 -------
Housekeeping: re-classify as invalid?
I wasn't able to find an "accepts-invalid" version of this bug in the database
for reference.  
That bug would've been fixed sometime between 4.0.1 and 4.0.2.  


-- 


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


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

* [Bug c++/24243] [4.0 regression] lookup fails to match to function call, const-sensitive
  2005-10-06 19:20 [Bug c++/24243] New: [4.0 regression] lookup fails to match to function call, const-sensitive fang at csl dot cornell dot edu
                   ` (7 preceding siblings ...)
  2006-03-11 22:11 ` fang at csl dot cornell dot edu
@ 2006-06-04 19:41 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-06-04 19:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from mmitchel at gcc dot gnu dot org  2006-06-04 19:41 -------
Submitter agrees code is invalid.


-- 

mmitchel at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2006-06-04 19:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-06 19:20 [Bug c++/24243] New: [4.0 regression] lookup fails to match to function call, const-sensitive fang at csl dot cornell dot edu
2005-10-06 19:22 ` [Bug c++/24243] " fang at csl dot cornell dot edu
2005-10-06 19:48 ` pinskia at gcc dot gnu dot org
2005-10-06 20:30 ` fang at csl dot cornell dot edu
2005-10-06 21:28 ` fang at csl dot cornell dot edu
2005-10-06 21:41 ` rguenth at gcc dot gnu dot org
2005-10-06 21:47 ` fang at csl dot cornell dot edu
2005-10-06 23:38 ` fang at csl dot cornell dot edu
2006-03-11 22:11 ` fang at csl dot cornell dot edu
2006-06-04 19:41 ` mmitchel 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).