* [Bug libstdc++/48113] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
@ 2011-03-14 14:09 ` redi at gcc dot gnu.org
2011-03-14 14:19 ` [Bug libstdc++/48113] [4.6 Regression] " redi at gcc dot gnu.org
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-14 14:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.03.14 14:09:41
Ever Confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-14 14:09:41 UTC ---
harrumph, I thought we'd solved these problems with the volatile overloads,
apparently not. I'll look into it later
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libstdc++/48113] [4.6 Regression] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
2011-03-14 14:09 ` [Bug libstdc++/48113] " redi at gcc dot gnu.org
@ 2011-03-14 14:19 ` redi at gcc dot gnu.org
2011-03-14 14:26 ` [Bug libstdc++/48113] [4.6/4.7 " rguenth at gcc dot gnu.org
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-14 14:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.6/4.7 Regression] |[4.6 Regression] [C++0x]
|[C++0x] bind with tuple |bind with tuple argument
|argument fails |fails
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-14 14:19:36 UTC ---
N.B. as a workaround you can specify the return type of the bind expression:
std::bind<void>(&test_1, std::tuple<int>(tst))
^^^^^^
This avoids the problem code, which is trying to determine the return type.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libstdc++/48113] [4.6/4.7 Regression] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
2011-03-14 14:09 ` [Bug libstdc++/48113] " redi at gcc dot gnu.org
2011-03-14 14:19 ` [Bug libstdc++/48113] [4.6 Regression] " redi at gcc dot gnu.org
@ 2011-03-14 14:26 ` rguenth at gcc dot gnu.org
2011-03-14 16:23 ` redi at gcc dot gnu.org
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-03-14 14:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.6.0
Summary|[4.6 Regression] [C++0x] |[4.6/4.7 Regression]
|bind with tuple argument |[C++0x] bind with tuple
|fails |argument fails
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libstdc++/48113] [4.6/4.7 Regression] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
` (2 preceding siblings ...)
2011-03-14 14:26 ` [Bug libstdc++/48113] [4.6/4.7 " rguenth at gcc dot gnu.org
@ 2011-03-14 16:23 ` redi at gcc dot gnu.org
2011-03-14 17:24 ` jason at gcc dot gnu.org
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-14 16:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-14 16:22:44 UTC ---
Jason, could you take a look at this reduced testcase, which has no libstdc++
dependency?
template<typename T> T declval();
struct tuple { };
struct F1
{
void operator()(tuple);
};
typedef void (*F2)(tuple);
template<typename F, typename T>
struct Bind
{
decltype( F()(declval<T&>()) )
f();
decltype( F()(declval<volatile T&>()) )
f() volatile;
};
int main()
{
Bind<F1, tuple>().f(); // OK
Bind<F2, tuple>().f(); // ERROR
}
This shows that SFINAE removes the Bind::f() volatile overload if F is a
functor, but not if it's a function pointer. I can't see why it should be
different.
Is this a FE bug, or do I need to handle function pointers differently in
std::bind? Thanks
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libstdc++/48113] [4.6/4.7 Regression] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
` (3 preceding siblings ...)
2011-03-14 16:23 ` redi at gcc dot gnu.org
@ 2011-03-14 17:24 ` jason at gcc dot gnu.org
2011-03-14 17:34 ` jason at gcc dot gnu.org
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-03-14 17:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |jason at gcc dot gnu.org
|gnu.org |
--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-03-14 17:24:36 UTC ---
SFINAE is not removing an overload; it doesn't work like that. SFINAE only
applies to function templates, not non-template member functions of class
templates. It's just that for some reason we aren't complaining about the
functor case. Reduced further:
struct A { };
volatile A& f();
struct F1
{
void operator()(A);
};
typedef void (*F2)(A);
typedef decltype (F1()(f())) t1;
typedef decltype (F2()(f())) t2;
The inconsistency is odd. I would expect both lines to give an error.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libstdc++/48113] [4.6/4.7 Regression] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
` (4 preceding siblings ...)
2011-03-14 17:24 ` jason at gcc dot gnu.org
@ 2011-03-14 17:34 ` jason at gcc dot gnu.org
2011-03-14 17:56 ` paolo.carlini at oracle dot com
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-03-14 17:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |NEW
AssignedTo|jason at gcc dot gnu.org |unassigned at gcc dot
| |gnu.org
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2011-03-14 17:33:44 UTC ---
Indeed, EDG 4.2 rejects both. So the bug report is indeed a library issue.
I'll open a separate report for the accepts-invalid example.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libstdc++/48113] [4.6/4.7 Regression] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
` (5 preceding siblings ...)
2011-03-14 17:34 ` jason at gcc dot gnu.org
@ 2011-03-14 17:56 ` paolo.carlini at oracle dot com
2011-03-14 18:02 ` redi at gcc dot gnu.org
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-03-14 17:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-03-14 17:55:53 UTC ---
I suspect Jon reduced the testcase a bit too much, because we have been through
this kind of discussion/misunderstanding already, indeed normally we have only
function *templates* in the actual code, no SFINAE to the help otherwise,
agreed.
Thanks Jon (and Jason) for looking into this.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libstdc++/48113] [4.6/4.7 Regression] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
` (6 preceding siblings ...)
2011-03-14 17:56 ` paolo.carlini at oracle dot com
@ 2011-03-14 18:02 ` redi at gcc dot gnu.org
2011-03-14 18:04 ` redi at gcc dot gnu.org
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-14 18:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-14 18:01:51 UTC ---
Doh, yes I got carried away reducing it and made it no longer a template
function, so of course SFINAE doesn't apply - sorry!
Should it apply in the case below?
template<typename T> T declval();
struct tuple { };
struct F1
{
void operator()(tuple);
};
typedef void (*F2)(tuple);
template<typename F, typename T>
struct Bind
{
template<typename A, typename R = decltype( F()(declval<T&>()) )>
R f(A);
template<typename A, typename R = decltype( F()(declval<volatile T&>()) )>
R f(A) volatile;
};
int main()
{
Bind<F1, tuple>().f(0); // OK
Bind<F2, tuple>().f(0); // ERROR
}
Currently Bind::f() volatile gives an error during overload resolution but the
other overload doesn't. Will your fix make both fail?
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libstdc++/48113] [4.6/4.7 Regression] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
` (7 preceding siblings ...)
2011-03-14 18:02 ` redi at gcc dot gnu.org
@ 2011-03-14 18:04 ` redi at gcc dot gnu.org
2011-03-14 18:10 ` redi at gcc dot gnu.org
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-14 18:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-14 18:03:52 UTC ---
(In reply to comment #7)
> Currently Bind::f() volatile gives an error during overload resolution but the
> other overload doesn't. Will your fix make both fail?
brain really not firing today ... I meant:
Currently Bind::f() volatile gives an error for F2, but not F1. Will you fix
make both fail?
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug libstdc++/48113] [4.6/4.7 Regression] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
` (8 preceding siblings ...)
2011-03-14 18:04 ` redi at gcc dot gnu.org
@ 2011-03-14 18:10 ` redi at gcc dot gnu.org
2011-03-14 18:48 ` [Bug c++/48113] " jason at gcc dot gnu.org
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-14 18:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-14 18:10:19 UTC ---
here's one even closer to what we actually have in the library, where the
default template argument R involves the deduced type A as well:
template<typename T> T declval();
struct tuple { };
struct F1
{
void operator()(tuple, int);
};
typedef void (*F2)(tuple, int);
template<typename F, typename T>
struct Bind
{
template<typename A,
typename R = decltype( F()(declval<T&>(), A()) )>
R f(A);
template<typename A,
typename R = decltype( F()(declval<volatile T&>(), A()) )>
R f(A) volatile;
};
int main()
{
Bind<F1, tuple>().f(0); // OK
Bind<F2, tuple>().f(0); // ERROR
}
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/48113] [4.6/4.7 Regression] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
` (9 preceding siblings ...)
2011-03-14 18:10 ` redi at gcc dot gnu.org
@ 2011-03-14 18:48 ` jason at gcc dot gnu.org
2011-03-14 18:59 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-03-14 18:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Component|libstdc++ |c++
AssignedTo|unassigned at gcc dot |jason at gcc dot gnu.org
|gnu.org |
--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> 2011-03-14 18:47:53 UTC ---
That is indeed a SFINAE bug.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/48113] [4.6/4.7 Regression] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
` (10 preceding siblings ...)
2011-03-14 18:48 ` [Bug c++/48113] " jason at gcc dot gnu.org
@ 2011-03-14 18:59 ` redi at gcc dot gnu.org
2011-03-16 20:03 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-14 18:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-14 18:59:45 UTC ---
(In reply to comment #10)
> That is indeed a SFINAE bug.
phew! cos I'm all out of better ideas for fixing std::bind ;)
Thanks for your help, sorry for the mixup with my overeager testcase reduction,
but at least we found a new bug out of it
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/48113] [4.6/4.7 Regression] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
` (11 preceding siblings ...)
2011-03-14 18:59 ` redi at gcc dot gnu.org
@ 2011-03-16 20:03 ` jason at gcc dot gnu.org
2011-03-16 20:04 ` jason at gcc dot gnu.org
2011-03-16 20:24 ` jason at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-03-16 20:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
--- Comment #12 from Jason Merrill <jason at gcc dot gnu.org> 2011-03-16 20:03:07 UTC ---
Author: jason
Date: Wed Mar 16 20:03:01 2011
New Revision: 171064
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171064
Log:
PR c++/48113
* typeck.c (convert_for_initialization): Use
perform_implicit_conversion_flags.
* call.c (standard_conversion): If LOOKUP_PREFER_RVALUE, set
rvaluedness_matches_p on ck_rvalue.
(convert_like_real) [ck_rvalue]: And restore it here.
Added:
branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/sfinae6.C
Modified:
branches/gcc-4_6-branch/gcc/cp/ChangeLog
branches/gcc-4_6-branch/gcc/cp/call.c
branches/gcc-4_6-branch/gcc/cp/typeck.c
branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/initlist38.C
branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/pr45908.C
branches/gcc-4_6-branch/gcc/testsuite/g++.old-deja/g++.jason/conversion11.C
branches/gcc-4_6-branch/gcc/testsuite/g++.old-deja/g++.law/arg11.C
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/48113] [4.6/4.7 Regression] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
` (12 preceding siblings ...)
2011-03-16 20:03 ` jason at gcc dot gnu.org
@ 2011-03-16 20:04 ` jason at gcc dot gnu.org
2011-03-16 20:24 ` jason at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-03-16 20:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
--- Comment #13 from Jason Merrill <jason at gcc dot gnu.org> 2011-03-16 20:04:01 UTC ---
Author: jason
Date: Wed Mar 16 20:03:56 2011
New Revision: 171067
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171067
Log:
PR c++/48113
* typeck.c (convert_for_initialization): Use
perform_implicit_conversion_flags.
* call.c (standard_conversion): If LOOKUP_PREFER_RVALUE, set
rvaluedness_matches_p on ck_rvalue.
(convert_like_real) [ck_rvalue]: And restore it here.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/sfinae6.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
trunk/gcc/cp/typeck.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/cpp0x/initlist38.C
trunk/gcc/testsuite/g++.dg/cpp0x/pr45908.C
trunk/gcc/testsuite/g++.old-deja/g++.jason/conversion11.C
trunk/gcc/testsuite/g++.old-deja/g++.law/arg11.C
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/48113] [4.6/4.7 Regression] [C++0x] bind with tuple argument fails
2011-03-14 14:02 [Bug libstdc++/48113] New: [C++0x] bind with tuple argument fails martin.kronbichler at it dot uu.se
` (13 preceding siblings ...)
2011-03-16 20:04 ` jason at gcc dot gnu.org
@ 2011-03-16 20:24 ` jason at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-03-16 20:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48113
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #14 from Jason Merrill <jason at gcc dot gnu.org> 2011-03-16 20:22:57 UTC ---
Fixed.
^ permalink raw reply [flat|nested] 16+ messages in thread