public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/66998] New: not_fn invocation is not SFINAE friendly
@ 2015-07-24 16:15 tomaszkam at gmail dot com
  2015-07-24 16:28 ` [Bug libstdc++/66998] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: tomaszkam at gmail dot com @ 2015-07-24 16:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66998

            Bug ID: 66998
           Summary: not_fn invocation is not SFINAE friendly
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tomaszkam at gmail dot com
  Target Milestone: ---

According to the
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4529.html#func.not_fn
the following invocations not_fn(f)(args...) and !INVOKE(f, args...) (in case
when f is function object it can be simplified to !f(args)). However the in
current implementation they behavior differs in case when they are used in
SFINAE context.

For example:
#include <experimental/functional>

template<typename F, typename Arg>
auto foo1(F f, Arg arg) -> decltype(!f(arg)) { return !f(arg); }

template<typename F, typename Arg>
auto foo1(F f, Arg arg) -> decltype(!f()) { return !f(); }

template<typename F, typename Arg>
auto foo2(F f, Arg arg) -> decltype(not_fn(f)(arg)) { return not_fn(f)(arg); }

template<typename F, typename Arg>
auto foo2(F f, Arg arg) -> decltype(not_fn(f)()) { return not_fn(f)(); }

struct negator
{
    bool operator()(int) const { return false; }
    void operator()() const {}
};

int main()
{
    foo1(negator{}, 1);
//    foo2(negator{}, 1)); //Shall be equivalent to line above. Produces an
compilation error cause by instatiation error during return type deduction.
};

The problem is caused by the use of return type deduction (decltype(auto))
instead of decltype(expr) in the implementation of not_fn. Notice that such use
does not break the function precondition placed in requires clause.


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

* [Bug libstdc++/66998] not_fn invocation is not SFINAE friendly
  2015-07-24 16:15 [Bug libstdc++/66998] New: not_fn invocation is not SFINAE friendly tomaszkam at gmail dot com
@ 2015-07-24 16:28 ` redi at gcc dot gnu.org
  2015-07-24 16:32 ` tomaszkam at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2015-07-24 16:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66998

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-07-24
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I'm not convinced that the wording *really* requires them to be equivalent in
all contexts, i.e. even when !INVOKE(fd, ...) is not a valid expression ... but
since you wrote the proposal I guess we can assume that's what you intended :-)

It's certainly a nice QoI improvement. I was basically lazy when I implemented
it and used decltype(auto) because it's convenient.


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

* [Bug libstdc++/66998] not_fn invocation is not SFINAE friendly
  2015-07-24 16:15 [Bug libstdc++/66998] New: not_fn invocation is not SFINAE friendly tomaszkam at gmail dot com
  2015-07-24 16:28 ` [Bug libstdc++/66998] " redi at gcc dot gnu.org
@ 2015-07-24 16:32 ` tomaszkam at gmail dot com
  2015-09-03 14:36 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: tomaszkam at gmail dot com @ 2015-07-24 16:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66998

--- Comment #2 from Tomasz Kamiński <tomaszkam at gmail dot com> ---
Sorry for missing using declaration. 

> It's certainly a nice QoI improvement. I was basically lazy when I implemented it and used decltype(auto) because it's convenient.

Yes, the decltype(auto) is convenient but the hard error produced in SFINAE
context make it acutally unusable in library. Just think of the mess that would
be caused by:
template<typename C>
delctype(auto) begin(C&& c) { return std::forward<C>(c).begin(); }

The not_fn is also not working with member pointers:
#include <experimental/functional>

using namespace std::experimental;

struct A
{
    bool mem;
};

int main()
{
    not_fn(&A::mem)(A{});
};
Should I create separate issue?
>From gcc-bugs-return-493258-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jul 24 16:41:06 2015
Return-Path: <gcc-bugs-return-493258-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 34602 invoked by alias); 24 Jul 2015 16:41:06 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 34387 invoked by uid 48); 24 Jul 2015 16:41:02 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/66998] not_fn invocation is not SFINAE friendly
Date: Fri, 24 Jul 2015 16:41:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libstdc++
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: redi at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-66998-4-JC2PxUFuaj@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66998-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66998-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-07/txt/msg02148.txt.bz2
Content-length: 365

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66998

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Tomasz Kamiński from comment #2)
> Should I create separate issue?

Oops, no we can deal with both under this PR.

If I commit my invoke() implementation then we can just use that, and it will
solve the member pointer issue.
>From gcc-bugs-return-493259-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jul 24 16:45:42 2015
Return-Path: <gcc-bugs-return-493259-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 82503 invoked by alias); 24 Jul 2015 16:45:42 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 82254 invoked by uid 48); 24 Jul 2015 16:45:38 -0000
From: "vries at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/66873] fortran variant of outer-1.c not parallelized by autopar
Date: Fri, 24 Jul 2015 16:45:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 6.0
X-Bugzilla-Keywords: missed-optimization, patch
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: vries at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-66873-4-WrwfaH11Jh@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66873-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66873-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-07/txt/msg02149.txt.bz2
Content-length: 772

https://gcc.gnu.org/bugzilla/show_bug.cgi?idf873

--- Comment #9 from vries at gcc dot gnu.org ---
(In reply to vries from comment #7)
> Created attachment 35986 [details]
> Updated tentative patch
>
> I found that always doing graphite before parloops resulted in failures to
> parallelize reduction testcases.
>

That was due to not using -ffast-math.

By using this ( https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01863.html )
approved patch, we no longer have that problem.

However, we run into: PR66997 - outer loop reduction fails to parallelize with
graphite.

And the runtime of graphite is excessive in some cases, with prevents us from
using graphite by default, f.i. Bug 53852 - [4.9/5/6 Regression]
-ftree-loop-linear: large compile time / memory usage.


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

* [Bug libstdc++/66998] not_fn invocation is not SFINAE friendly
  2015-07-24 16:15 [Bug libstdc++/66998] New: not_fn invocation is not SFINAE friendly tomaszkam at gmail dot com
  2015-07-24 16:28 ` [Bug libstdc++/66998] " redi at gcc dot gnu.org
  2015-07-24 16:32 ` tomaszkam at gmail dot com
@ 2015-09-03 14:36 ` redi at gcc dot gnu.org
  2015-09-03 15:11 ` redi at gcc dot gnu.org
  2015-09-03 15:12 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-03 14:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66998

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Thu Sep  3 14:36:03 2015
New Revision: 227448

URL: https://gcc.gnu.org/viewcvs?rev=227448&root=gcc&view=rev
Log:
Make std::experimental::not_fn SFINAE-friendly.

        PR libstdc++/66998
        * include/experimental/functional (_Not_fn): Add exception
        specifications and non-deduced return types.
        (not_fn): Add exception specification and wrap pointer-to-member.
        * testsuite/experimental/functional/not_fn.cc: Test in SFINAE context
        and test pointer-to-member.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/experimental/functional
    trunk/libstdc++-v3/testsuite/experimental/functional/not_fn.cc


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

* [Bug libstdc++/66998] not_fn invocation is not SFINAE friendly
  2015-07-24 16:15 [Bug libstdc++/66998] New: not_fn invocation is not SFINAE friendly tomaszkam at gmail dot com
                   ` (2 preceding siblings ...)
  2015-09-03 14:36 ` redi at gcc dot gnu.org
@ 2015-09-03 15:11 ` redi at gcc dot gnu.org
  2015-09-03 15:12 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-03 15:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66998

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Thu Sep  3 15:10:52 2015
New Revision: 227455

URL: https://gcc.gnu.org/viewcvs?rev=227455&root=gcc&view=rev
Log:
Make std::experimental::not_fn SFINAE-friendly.

        PR libstdc++/66998
        * include/experimental/functional (_Not_fn): Add exception
        specifications and non-deduced return types.
        (not_fn): Add exception specification and wrap pointer-to-member.
        * testsuite/experimental/functional/not_fn.cc: Test in SFINAE context
        and test pointer-to-member.

Modified:
    branches/gcc-5-branch/libstdc++-v3/ChangeLog
    branches/gcc-5-branch/libstdc++-v3/include/experimental/functional
   
branches/gcc-5-branch/libstdc++-v3/testsuite/experimental/functional/not_fn.cc


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

* [Bug libstdc++/66998] not_fn invocation is not SFINAE friendly
  2015-07-24 16:15 [Bug libstdc++/66998] New: not_fn invocation is not SFINAE friendly tomaszkam at gmail dot com
                   ` (3 preceding siblings ...)
  2015-09-03 15:11 ` redi at gcc dot gnu.org
@ 2015-09-03 15:12 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-03 15:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66998

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |5.3

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed


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

end of thread, other threads:[~2015-09-03 15:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-24 16:15 [Bug libstdc++/66998] New: not_fn invocation is not SFINAE friendly tomaszkam at gmail dot com
2015-07-24 16:28 ` [Bug libstdc++/66998] " redi at gcc dot gnu.org
2015-07-24 16:32 ` tomaszkam at gmail dot com
2015-09-03 14:36 ` redi at gcc dot gnu.org
2015-09-03 15:11 ` redi at gcc dot gnu.org
2015-09-03 15:12 ` redi at gcc dot gnu.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).