public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
@ 2011-05-19  7:27 flast at flast dot jp
  2011-05-19 12:04 ` [Bug c++/49058] " redi at gcc dot gnu.org
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: flast at flast dot jp @ 2011-05-19  7:27 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: [C++0x] Bind no-arguments functor failed using
                    std::bind with -pedantic option.
           Product: gcc
           Version: 4.5.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: flast@flast.jp


GCC rejects following code with -pedantic option.

==== testcase.cc ====
#include <functional>

struct F
{
    void
    operator()();
};

void f()
{
    std::bind( F() );
}
====

==== output ====
$ g++-4.5 -std=c++0x -pedantic testcase.cc
In file included from testcase.cc:1:0:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.5.4/../../../../include/c++/4.5.4/functional:
In instantiation of 'std::_Bind<F()>':
testcase.cc:11:20:   instantiated from here
/usr/local/lib/gcc/i686-pc-linux-gnu/4.5.4/../../../../include/c++/4.5.4/functional:1174:39:
error: no match for call to '(const F) ()'
testcase.cc:5:5: note: candidate is: void F::operator()() <near match>
====

After GCC 4.6, also faild with no-arguments lambda-expression.

==== testcase.cc ====
#include <functional>

void f()
{
    std::bind( []{} );
}
====

==== output ====
$ g++-4.6 -std=c++0x -pedantic testcase.cc
In file included from testcase.cc:1:0:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:
In instantiation of 'std::_Bind<f()::<lambda()>()>':
testcase.cc:5:21:   instantiated from here
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:1227:32:
error: no match for call to '(volatile f()::<lambda()>) ()'
testcase.cc:5:17: note: candidates are:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:1227:32:
note: void (*)() <conversion>
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:1227:32:
note:   candidate expects 0 arguments, 1 provided
testcase.cc:5:17: note: f()::<lambda()> <near match>
testcase.cc:5:17: note:   no known conversion for implicit 'this' parameter
from 'volatile f()::<lambda()>*' to 'const f()::<lambda()>*'
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:
In instantiation of 'std::_Bind<f()::<lambda()>()>':
testcase.cc:5:21:   instantiated from here
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:1240:38:
error: no match for call to '(const volatile f()::<lambda()>) ()'
testcase.cc:5:17: note: candidates are:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:1240:38:
note: void (*)() <conversion>
/usr/local/lib/gcc/i686-pc-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:1240:38:
note:   candidate expects 0 arguments, 1 provided
testcase.cc:5:17: note: f()::<lambda()> <near match>
testcase.cc:5:17: note:   no known conversion for implicit 'this' parameter
from 'const volatile f()::<lambda()>*' to 'const f()::<lambda()>*'
====

gcc-4.5 (GCC) 4.5.4 20110512 (prerelease) - Failed
gcc-4.6 (GCC) 4.6.1 20110513 (prerelease) - Failed
gcc-4.7 (GCC) 4.7.0 20110517 (experimental) - Failed


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

* [Bug c++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
@ 2011-05-19 12:04 ` redi at gcc dot gnu.org
  2011-05-19 15:59 ` jason at gcc dot gnu.org
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-19 12:04 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-19 10:47:15 UTC ---
Jason, this works without -pedantic but fails with:

template<typename T> T val();

struct F1
{
    void operator()();
};

template<typename... T> struct tuple { };

template<typename T, typename... V>
T
call(T&& t, tuple<V...>)
{ return t; }

template<typename F, typename... T>
struct Bind
{
    template<typename... A, typename R
      = decltype( val<F>()( call(val<T>(), tuple<A...>())... ) )>
    R f(A&&...);

    template<typename... A, typename R
      = decltype( val<const F>()( call(val<T>(), tuple<A...>())... ) )>
    R f(A&&...) const;
};

int main()
{
    Bind<F1>().f();
}

Is this code relying on a G++ extension?

The parameter pack T has zero elements so the expansion:
    call(val<T>(), tuple<A...>())... )
expands to nothing, and in -pedantic mode that seems to prevent the parameter
pack A from participating in type deduction, so SFINAE doesn't remove the
overload.


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

* [Bug c++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
  2011-05-19 12:04 ` [Bug c++/49058] " redi at gcc dot gnu.org
@ 2011-05-19 15:59 ` jason at gcc dot gnu.org
  2011-05-19 16:23 ` jason at gcc dot gnu.org
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-19 15:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011.05.19 15:43:41
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-19 15:43:41 UTC ---
This has nothing to do with variadics; the same error occurs with

template<typename T> T val();

struct F1
{   
    void operator()();
};

template<typename F>
struct Bind
{   
    template<typename R
      = decltype( val<F>()( ) )>
    R f();

    template<typename R
      = decltype( val<const F>()( ) )>
    R f() const;
};

int main()
{   
    Bind<F1>().f();
}

The problem is that F1::operator() is non-const, so when we instantiate
Bind<F1>, val<const F>() is ill-formed.  And this error is not dependent on  
EDG also rejects this testcase.  The bug is that we silently accept it without
-pedantic; we should be giving a pedwarn.


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

* [Bug c++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
  2011-05-19 12:04 ` [Bug c++/49058] " redi at gcc dot gnu.org
  2011-05-19 15:59 ` jason at gcc dot gnu.org
@ 2011-05-19 16:23 ` jason at gcc dot gnu.org
  2011-05-19 16:24 ` [Bug libstdc++/49058] " jason at gcc dot gnu.org
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-19 16:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-19 16:09:05 UTC ---
Created attachment 24291
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24291
Fix

Here's a fix, which breaks bind, so I'm not going to check it in yet.  Is there
already a libstdc++ bug for this issue that I can mark as blocking this one?


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (2 preceding siblings ...)
  2011-05-19 16:23 ` jason at gcc dot gnu.org
@ 2011-05-19 16:24 ` jason at gcc dot gnu.org
  2011-05-19 16:37 ` jason at gcc dot gnu.org
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-19 16:24 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |redi at gcc dot gnu.org

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-19 16:10:58 UTC ---
...and adding Jonathan to CC.  See my earlier comments: a compiler bug was
masking a library bug.


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (3 preceding siblings ...)
  2011-05-19 16:24 ` [Bug libstdc++/49058] " jason at gcc dot gnu.org
@ 2011-05-19 16:37 ` jason at gcc dot gnu.org
  2011-05-19 17:19 ` redi at gcc dot gnu.org
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-19 16:37 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
          Component|c++                         |libstdc++
         AssignedTo|jason at gcc dot gnu.org    |unassigned at gcc dot
                   |                            |gnu.org

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-19 16:09:59 UTC ---
Actually I'll just unassign myself and change the category.


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (4 preceding siblings ...)
  2011-05-19 16:37 ` jason at gcc dot gnu.org
@ 2011-05-19 17:19 ` redi at gcc dot gnu.org
  2011-05-22 21:02 ` paolo.carlini at oracle dot com
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-19 17:19 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |redi at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-19 16:52:35 UTC ---
thanks, I'll deal with the lib bug


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (5 preceding siblings ...)
  2011-05-19 17:19 ` redi at gcc dot gnu.org
@ 2011-05-22 21:02 ` paolo.carlini at oracle dot com
  2011-05-22 21:45 ` redi at gcc dot gnu.org
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-22 21:02 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paolo.carlini at oracle dot
                   |                            |com

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-22 20:44:49 UTC ---
Guys, do we have solid reasons to believe that the below totally stupid tweak
is not Ok? Because it passes the testsuite and the new testcases here with
-pedantic:

Index: include/std/functional
===================================================================
--- include/std/functional    (revision 174039)
+++ include/std/functional    (working copy)
@@ -1210,7 +1210,7 @@

       // Call as const
       template<typename... _Args, typename _Result
-    = decltype( std::declval<const _Functor>()(
+    = decltype( std::declval<_Functor>()(
           _Mu<_Bound_args>()( std::declval<const _Bound_args&>(),
                   std::declval<tuple<_Args...>&>() )... ) )>
     _Result
@@ -1223,7 +1223,7 @@

       // Call as volatile
       template<typename... _Args, typename _Result
-    = decltype( std::declval<volatile _Functor>()(
+    = decltype( std::declval<_Functor>()(
           _Mu<_Bound_args>()( std::declval<volatile _Bound_args&>(),
                   std::declval<tuple<_Args...>&>() )... ) )>
     _Result
@@ -1236,7 +1236,7 @@

       // Call as const volatile
       template<typename... _Args, typename _Result
-    = decltype( std::declval<const volatile _Functor>()(
+    = decltype( std::declval<_Functor>()(
           _Mu<_Bound_args>()( std::declval<const volatile _Bound_args&>(),
                   std::declval<tuple<_Args...>&>() )... ) )>
     _Result


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (6 preceding siblings ...)
  2011-05-22 21:02 ` paolo.carlini at oracle dot com
@ 2011-05-22 21:45 ` redi at gcc dot gnu.org
  2011-05-22 21:52 ` redi at gcc dot gnu.org
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-22 21:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-22 21:23:12 UTC ---
It would be wrong though, consider:

struct F {
  int operator();
  void operator() const;
};

the decltype would detect the return type as 'int' but the function body would
return void, because _M_f is const


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (7 preceding siblings ...)
  2011-05-22 21:45 ` redi at gcc dot gnu.org
@ 2011-05-22 21:52 ` redi at gcc dot gnu.org
  2011-05-22 21:53 ` redi at gcc dot gnu.org
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-22 21:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-22 21:29:56 UTC ---
For a complete example:

struct F {
  int operator()() const { return 0; }
  void operator()() const { };
};

int main()
{
  auto const b = std::bind( F() );
  int i = b();  // b is const here, must return int
}

[func.bind.bind] p3 requires that the cv-qualifiers of the call wrapper are
used when calling the target object


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (8 preceding siblings ...)
  2011-05-22 21:52 ` redi at gcc dot gnu.org
@ 2011-05-22 21:53 ` redi at gcc dot gnu.org
  2011-05-22 22:05 ` redi at gcc dot gnu.org
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-22 21:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-22 21:24:16 UTC ---
Duh, sorry, that should have been

struct F {
  int operator()();
  void operator()() const;
};


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (9 preceding siblings ...)
  2011-05-22 21:53 ` redi at gcc dot gnu.org
@ 2011-05-22 22:05 ` redi at gcc dot gnu.org
  2011-05-22 22:10 ` paolo.carlini at oracle dot com
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-22 22:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-22 21:32:05 UTC ---
(In reply to comment #10)
> For a complete example:
> 
> struct F {
>   int operator()() const { return 0; }
>   void operator()() const { };

sigh, I should really take a bit longer before hitting send!

struct F {
  int operator()() const { return 0; }
  void operator()() { };
};


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (10 preceding siblings ...)
  2011-05-22 22:05 ` redi at gcc dot gnu.org
@ 2011-05-22 22:10 ` paolo.carlini at oracle dot com
  2011-05-22 22:35 ` paolo.carlini at oracle dot com
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-22 22:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-22 21:47:04 UTC ---
Ok, let's make sure to have something similar in the testsuite.

And, well, I still believe a tangle of auto return types shouldn't be really
necessary in order to solve the problem, to be honest ;)


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (11 preceding siblings ...)
  2011-05-22 22:10 ` paolo.carlini at oracle dot com
@ 2011-05-22 22:35 ` paolo.carlini at oracle dot com
  2011-05-22 22:51 ` paolo.carlini at oracle dot com
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-22 22:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-22 22:20:24 UTC ---
Sorry, hit return inadvertently. Anyway, the idea would be, instead of just
writing:

  const _Functor

writing something like:

  typename conditional<(sizeof...(_Args) >= 0,
                       typename add_const<_Functor>::type,
                       typename add_const<_Functor>::type>::type

I think that should work, it does in some simple tests I did, and all in all,
properly polished, doesn't even look too bad, IMHO.


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (12 preceding siblings ...)
  2011-05-22 22:35 ` paolo.carlini at oracle dot com
@ 2011-05-22 22:51 ` paolo.carlini at oracle dot com
  2011-05-22 23:17 ` paolo.carlini at oracle dot com
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-22 22:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-22 22:17:10 UTC ---
What about creating an artificially dependent context, thus amenable to SFINAE,
like:

// Call as const
template<typename... _Args, typename _Result
  = decltype( std::declval<typename conditional<(sizeof...(_Args) >= 0),
    typename add_const<_Functor>::type,
typename add_const<_Functor>::type>::type>()

(
              _Mu<_Bound_args>()( std::declval<const _Bound_args&>(),
                                  std::declval<tuple<_Args...>&>() )... ) )>
        _Result


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (13 preceding siblings ...)
  2011-05-22 22:51 ` paolo.carlini at oracle dot com
@ 2011-05-22 23:17 ` paolo.carlini at oracle dot com
  2011-05-22 23:47 ` paolo.carlini at oracle dot com
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-22 23:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-22 22:30:55 UTC ---
This is something which actually passes the testsuite, and the tests here and
the new test explained by Jon. Maybe something even more clean along the same
lines is possible, but I would be already pretty happy for now... assuming Jon
isn't able to figure out yet another regression ;)

////////////////////

Index: include/std/functional
===================================================================
--- include/std/functional    (revision 174044)
+++ include/std/functional    (working copy)
@@ -1210,7 +1210,8 @@

       // Call as const
       template<typename... _Args, typename _Result
-    = decltype( std::declval<const _Functor>()(
+    = decltype( std::declval<typename conditional<(sizeof...(_Args) >= 0),
+               typename add_const<_Functor>::type, void>::type>()(
           _Mu<_Bound_args>()( std::declval<const _Bound_args&>(),
                   std::declval<tuple<_Args...>&>() )... ) )>
     _Result
@@ -1223,7 +1224,8 @@

       // Call as volatile
       template<typename... _Args, typename _Result
-    = decltype( std::declval<volatile _Functor>()(
+    = decltype( std::declval<typename conditional<(sizeof...(_Args) >= 0),
+                       typename add_volatile<_Functor>::type, void>::type>()(
           _Mu<_Bound_args>()( std::declval<volatile _Bound_args&>(),
                   std::declval<tuple<_Args...>&>() )... ) )>
     _Result
@@ -1236,7 +1238,8 @@

       // Call as const volatile
       template<typename... _Args, typename _Result
-    = decltype( std::declval<const volatile _Functor>()(
+    = decltype( std::declval<typename conditional<(sizeof...(_Args) >= 0),
+                       typename add_cv<_Functor>::type, void>::type>()(
           _Mu<_Bound_args>()( std::declval<const volatile _Bound_args&>(),
                   std::declval<tuple<_Args...>&>() )... ) )>
     _Result


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (14 preceding siblings ...)
  2011-05-22 23:17 ` paolo.carlini at oracle dot com
@ 2011-05-22 23:47 ` paolo.carlini at oracle dot com
  2011-05-23  0:02 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-22 23:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #16 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-22 22:52:13 UTC ---
With enable_if becomes a tad more concise.

///////////////////

Index: include/std/functional
===================================================================
--- include/std/functional    (revision 174044)
+++ include/std/functional    (working copy)
@@ -1210,7 +1210,8 @@

       // Call as const
       template<typename... _Args, typename _Result
-    = decltype( std::declval<const _Functor>()(
+    = decltype( std::declval<typename enable_if<(sizeof...(_Args) >= 0),
+               typename add_const<_Functor>::type>::type>()(
           _Mu<_Bound_args>()( std::declval<const _Bound_args&>(),
                   std::declval<tuple<_Args...>&>() )... ) )>
     _Result
@@ -1223,7 +1224,8 @@

       // Call as volatile
       template<typename... _Args, typename _Result
-    = decltype( std::declval<volatile _Functor>()(
+    = decltype( std::declval<typename enable_if<(sizeof...(_Args) >= 0),
+                       typename add_volatile<_Functor>::type>::type>()(
           _Mu<_Bound_args>()( std::declval<volatile _Bound_args&>(),
                   std::declval<tuple<_Args...>&>() )... ) )>
     _Result
@@ -1236,7 +1238,8 @@

       // Call as const volatile
       template<typename... _Args, typename _Result
-    = decltype( std::declval<const volatile _Functor>()(
+    = decltype( std::declval<typename enable_if<(sizeof...(_Args) >= 0),
+                       typename add_cv<_Functor>::type>::type>()(
           _Mu<_Bound_args>()( std::declval<const volatile _Bound_args&>(),
                   std::declval<tuple<_Args...>&>() )... ) )>
     _Result


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (15 preceding siblings ...)
  2011-05-22 23:47 ` paolo.carlini at oracle dot com
@ 2011-05-23  0:02 ` redi at gcc dot gnu.org
  2011-05-23  0:30 ` paolo at gcc dot gnu.org
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-23  0:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #17 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-22 23:09:06 UTC ---
nice trick, if that passes the testsuite I'd check it in


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (16 preceding siblings ...)
  2011-05-23  0:02 ` redi at gcc dot gnu.org
@ 2011-05-23  0:30 ` paolo at gcc dot gnu.org
  2011-05-23  0:42 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-05-23  0:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #18 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-05-23 00:05:29 UTC ---
Author: paolo
Date: Mon May 23 00:05:24 2011
New Revision: 174048

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174048
Log:
2011-05-22  Jonathan Wakely  <jwakely.gcc@gmail.com>

    * testsuite/20_util/bind/cv_quals_2.cc: New.

2011-05-22  Paolo Carlini  <paolo.carlini@oracle.com>

    PR libstdc++/49058
    * include/std/functional (_Bind<_Functor(_Bound_args...)>::
    operator()(_Args&&...)): Don't cv qualify _Functor directly
    in the default template argument, SFINAE doesn't apply when
    the functor has no arguments.
    * testsuite/20_util/bind/49058_1.cc: New.
    * testsuite/20_util/bind/49058_2.cc: Likewise.

Added:
    trunk/libstdc++-v3/testsuite/20_util/bind/49058_1.cc
    trunk/libstdc++-v3/testsuite/20_util/bind/49058_2.cc
    trunk/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/std/functional


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (17 preceding siblings ...)
  2011-05-23  0:30 ` paolo at gcc dot gnu.org
@ 2011-05-23  0:42 ` paolo.carlini at oracle dot com
  2011-05-23  0:46 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-23  0:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #20 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-23 00:10:24 UTC ---
Thanks Jon. Thus, library issue fixed in mainline and 4_6-branch.

Jason, I think you can safely commit the compiler change in mainline...


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (18 preceding siblings ...)
  2011-05-23  0:42 ` paolo.carlini at oracle dot com
@ 2011-05-23  0:46 ` paolo.carlini at oracle dot com
  2011-05-23  0:47 ` paolo at gcc dot gnu.org
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-23  0:46 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
         AssignedTo|redi at gcc dot gnu.org     |jason at redhat dot com
   Target Milestone|---                         |4.6.1


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (19 preceding siblings ...)
  2011-05-23  0:46 ` paolo.carlini at oracle dot com
@ 2011-05-23  0:47 ` paolo at gcc dot gnu.org
  2011-05-23 15:58 ` jason at gcc dot gnu.org
  2011-05-25  0:05 ` paolo.carlini at oracle dot com
  22 siblings, 0 replies; 24+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-05-23  0:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #19 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-05-23 00:09:00 UTC ---
Author: paolo
Date: Mon May 23 00:08:52 2011
New Revision: 174049

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174049
Log:
2011-05-22  Jonathan Wakely  <jwakely.gcc@gmail.com>

    * testsuite/20_util/bind/cv_quals_2.cc: New.

2011-05-22  Paolo Carlini  <paolo.carlini@oracle.com>

    PR libstdc++/49058
    * include/std/functional (_Bind<_Functor(_Bound_args...)>::
    operator()(_Args&&...)): Don't cv qualify _Functor directly
    in the default template argument, SFINAE doesn't apply when
    the functor has no arguments.
    * testsuite/20_util/bind/49058_1.cc: New.
    * testsuite/20_util/bind/49058_2.cc: Likewise.

Added:
    branches/gcc-4_6-branch/libstdc++-v3/testsuite/20_util/bind/49058_1.cc
    branches/gcc-4_6-branch/libstdc++-v3/testsuite/20_util/bind/49058_2.cc
    branches/gcc-4_6-branch/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc
Modified:
    branches/gcc-4_6-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_6-branch/libstdc++-v3/include/std/functional


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (20 preceding siblings ...)
  2011-05-23  0:47 ` paolo at gcc dot gnu.org
@ 2011-05-23 15:58 ` jason at gcc dot gnu.org
  2011-05-25  0:05 ` paolo.carlini at oracle dot com
  22 siblings, 0 replies; 24+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-23 15:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #21 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-23 15:32:42 UTC ---
Author: jason
Date: Mon May 23 15:32:39 2011
New Revision: 174073

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174073
Log:
    PR c++/49058
    * call.c (splice_viable): Be strict in templates.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/sfinae24.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug libstdc++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.
  2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
                   ` (21 preceding siblings ...)
  2011-05-23 15:58 ` jason at gcc dot gnu.org
@ 2011-05-25  0:05 ` paolo.carlini at oracle dot com
  22 siblings, 0 replies; 24+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-25  0:05 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #22 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-24 23:37:29 UTC ---
Unless Jason wants to apply the C++ patch to the release branch too, this is
all done.


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

end of thread, other threads:[~2011-05-25  0:00 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-19  7:27 [Bug c++/49058] New: [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option flast at flast dot jp
2011-05-19 12:04 ` [Bug c++/49058] " redi at gcc dot gnu.org
2011-05-19 15:59 ` jason at gcc dot gnu.org
2011-05-19 16:23 ` jason at gcc dot gnu.org
2011-05-19 16:24 ` [Bug libstdc++/49058] " jason at gcc dot gnu.org
2011-05-19 16:37 ` jason at gcc dot gnu.org
2011-05-19 17:19 ` redi at gcc dot gnu.org
2011-05-22 21:02 ` paolo.carlini at oracle dot com
2011-05-22 21:45 ` redi at gcc dot gnu.org
2011-05-22 21:52 ` redi at gcc dot gnu.org
2011-05-22 21:53 ` redi at gcc dot gnu.org
2011-05-22 22:05 ` redi at gcc dot gnu.org
2011-05-22 22:10 ` paolo.carlini at oracle dot com
2011-05-22 22:35 ` paolo.carlini at oracle dot com
2011-05-22 22:51 ` paolo.carlini at oracle dot com
2011-05-22 23:17 ` paolo.carlini at oracle dot com
2011-05-22 23:47 ` paolo.carlini at oracle dot com
2011-05-23  0:02 ` redi at gcc dot gnu.org
2011-05-23  0:30 ` paolo at gcc dot gnu.org
2011-05-23  0:42 ` paolo.carlini at oracle dot com
2011-05-23  0:46 ` paolo.carlini at oracle dot com
2011-05-23  0:47 ` paolo at gcc dot gnu.org
2011-05-23 15:58 ` jason at gcc dot gnu.org
2011-05-25  0:05 ` paolo.carlini at oracle dot com

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