* [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