public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66841] New: [concepts] bogus error "invalid reference to function concept" when function concept is overloaded
@ 2015-07-11 18:17 eric.niebler at gmail dot com
  2015-07-12 20:40 ` [Bug c++/66841] " andrew.n.sutton at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: eric.niebler at gmail dot com @ 2015-07-11 18:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66841
           Summary: [concepts] bogus error "invalid reference to function
                    concept" when function concept is overloaded
           Product: gcc
           Version: c++-concepts
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

This is related to the discussion in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66834. Because of the kind
mismatch error described in 66834, the straightforward implementation of
Constructible doesn't work, and the concept must be overloaded. But once it's
overloaded, uses of it cause of "invalid reference to function concept" error.


template <class T, class U>
concept bool Same =
  __is_same_as(T, U);

template <class T, class U>
concept bool ExplicitlyConvertible() { return
  Same<T, U> ||
  requires(T&& t) {
    static_cast<U>((T&&)t);
  };
}

template <class T>
concept bool Constructible() { return
  requires {
    T{ };
  };
}

template <class T, class U>
concept bool Constructible() { return
  ExplicitlyConvertible<U, T>() ||
  requires (U&& u) {
    T{ (U&&)u };
  };
}

template <class T, class U, class V, class...Args>
concept bool Constructible() { return
  requires (U&& u, V&& v, Args&&...args) {
    T{ (U&&)u, (V&&)v, (Args&&)args... };
  };
}

template <class, class...>
constexpr bool core_constructible() { return false; }

template <class T, class...Args>
  requires Constructible<T, Args...>() // ERROR HERE
constexpr bool core_constructible() { return false; }


Yields:

../cmcstl2/scratch/constructible.cpp:40:23: error: invalid reference to
function concept ‘template<class T, class U, class V, class ... Args> constexpr
bool Constructible()’
 requires Constructible<T, Args...>()
                       ^
>From gcc-bugs-return-492046-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jul 11 18:18:27 2015
Return-Path: <gcc-bugs-return-492046-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 6616 invoked by alias); 11 Jul 2015 18:18:26 -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 6478 invoked by uid 55); 11 Jul 2015 18:18:13 -0000
From: "paolo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58734] [C++11] Template template parameter pack instantiation problem
Date: Sat, 11 Jul 2015 18:18:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: paolo 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-58734-4-bzBAUasNjH@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58734-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58734-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/msg00936.txt.bz2
Content-length: 489

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

--- Comment #4 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Sat Jul 11 18:17:41 2015
New Revision: 225713

URL: https://gcc.gnu.org/viewcvs?rev"5713&root=gcc&view=rev
Log:
2015-07-11  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/58734
        * g++.dg/cpp0x/variadic-ttp2.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic-ttp2.C
Modified:
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/66841] [concepts] bogus error "invalid reference to function concept" when function concept is overloaded
  2015-07-11 18:17 [Bug c++/66841] New: [concepts] bogus error "invalid reference to function concept" when function concept is overloaded eric.niebler at gmail dot com
@ 2015-07-12 20:40 ` andrew.n.sutton at gmail dot com
  2015-07-12 20:44 ` eric.niebler at gmail dot com
  2015-08-04 13:37 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: andrew.n.sutton at gmail dot com @ 2015-07-12 20:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Sutton <andrew.n.sutton at gmail dot com> ---
The program is ill-formed. In this line:

   requires Constructible<T, Args...>() // ERROR HERE

There's no single declaration of Constructible that can be matched to those
template arguments. You would need one with this signature: <typename T,
typename... Args>.

I think defining Constructible so that it backends into a type trait will give
you the behavior you're looking for.

template<typename T, typename... Args>
concept bool Constructible() {
  return std::is_constructible<T, Args...>::value;
}


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

* [Bug c++/66841] [concepts] bogus error "invalid reference to function concept" when function concept is overloaded
  2015-07-11 18:17 [Bug c++/66841] New: [concepts] bogus error "invalid reference to function concept" when function concept is overloaded eric.niebler at gmail dot com
  2015-07-12 20:40 ` [Bug c++/66841] " andrew.n.sutton at gmail dot com
@ 2015-07-12 20:44 ` eric.niebler at gmail dot com
  2015-08-04 13:37 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: eric.niebler at gmail dot com @ 2015-07-12 20:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Eric Niebler <eric.niebler at gmail dot com> ---
This answer is deeply unsatisfying. I want valid expressions, not traits. And
if std::is_constructible doesn't do *exactly* what I want (and it doesn't) I
have to author my own trait, when what I want to do is author my own concept.

I'm not trying to do anything exotic here. There should be a way to do it
without resorting to metaprogramming trickery and SFINAE.


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

* [Bug c++/66841] [concepts] bogus error "invalid reference to function concept" when function concept is overloaded
  2015-07-11 18:17 [Bug c++/66841] New: [concepts] bogus error "invalid reference to function concept" when function concept is overloaded eric.niebler at gmail dot com
  2015-07-12 20:40 ` [Bug c++/66841] " andrew.n.sutton at gmail dot com
  2015-07-12 20:44 ` eric.niebler at gmail dot com
@ 2015-08-04 13:37 ` jason at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2015-08-04 13:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Let's keep the variadic concepts discussion in 66834.

*** This bug has been marked as a duplicate of bug 66834 ***


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

end of thread, other threads:[~2015-08-04 13:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-11 18:17 [Bug c++/66841] New: [concepts] bogus error "invalid reference to function concept" when function concept is overloaded eric.niebler at gmail dot com
2015-07-12 20:40 ` [Bug c++/66841] " andrew.n.sutton at gmail dot com
2015-07-12 20:44 ` eric.niebler at gmail dot com
2015-08-04 13:37 ` jason 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).