public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66091] New: [c++-concepts] Overloading of member operators based on constraints rejected; regression from r211591
@ 2015-05-10  3:29 tom at honermann dot net
  2015-05-12 12:24 ` [Bug c++/66091] " andrew.n.sutton at gmail dot com
  2015-05-12 20:26 ` tom at honermann dot net
  0 siblings, 2 replies; 3+ messages in thread
From: tom at honermann dot net @ 2015-05-10  3:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66091
           Summary: [c++-concepts] Overloading of member operators based
                    on constraints rejected; regression from r211591
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tom at honermann dot net
  Target Milestone: ---

The following test case was accepted by r211591 of the c++-concepts branch, but
is rejected by r222769.  My interpretation of N4377 is that this test case
should be accepted.

$ cat t.cpp
template<typename T>
concept bool C1() {
    return requires() { typename T::type1; };
}
template<typename T>
concept bool C2() {
    return C1<T>()
        && requires() { typename T::type2; };
}
template<C1 T>
struct S {
    S& operator++()
        { return *this; }
    S& operator++()
        requires C2<T>()
        { return *this; }
};

# Compiling with r222769:
$ g++ -c -std=c++1z t.cpp 
t.cpp:14:8: error: ‘S<T>& S<T>::operator++()’ cannot be overloaded
     S& operator++()
        ^
t.cpp:12:8: error: with ‘S<T>& S<T>::operator++()’
     S& operator++()
        ^
>From gcc-bugs-return-485934-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun May 10 05:29:50 2015
Return-Path: <gcc-bugs-return-485934-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 103586 invoked by alias); 10 May 2015 05:29:48 -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 103547 invoked by uid 48); 10 May 2015 05:29:42 -0000
From: "yingpo.liao at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/66092] New: Concept can't check variadic template arguments
Date: Sun, 10 May 2015 05:29:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: yingpo.liao at gmail dot com
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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone
Message-ID: <bug-66092-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-05/txt/msg00774.txt.bz2
Content-length: 2586

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

            Bug ID: 66092
           Summary: Concept can't check variadic template arguments
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yingpo.liao at gmail dot com
  Target Milestone: ---

Concept can't check variadic template arguments (r222891).

The example code shows an implementation of a concept to check if all types are
the same via variadic template arguments. It will be okay if we directly print
out the results, but will fail (internal compiler error) if we apply the
concept to real cases, i.e., a foo() function.

$ svn info

Path: .
Working Copy Root Path:
/Users/liao/Downloads/gcc-branch-c++-concepts/c++-concepts
URL: svn://gcc.gnu.org/svn/gcc/branches/c++-concepts
Relative URL: ^/branches/c++-concepts
Repository Root: svn://gcc.gnu.org/svn/gcc
Repository UUID: 138bc75d-0d04-0410-961f-82ee72b054a4
Revision: 222891
Node Kind: directory
Schedule: normal
Last Changed Author: asutton
Last Changed Rev: 222891
Last Changed Date: 2015-05-07 15:25:15 -0500 (Thu, 07 May 2015)

$ cat test.cpp

#include <iostream>
#include <type_traits>

template <typename T, typename U, typename... Args>
requires (sizeof...(Args) == 0)
  constexpr decltype(auto) check()
  {
    return std::integral_constant<bool, __is_same_as(T, U)>();
  }

template <typename T, typename U, typename... Args>
requires (sizeof...(Args) > 0)
  constexpr decltype(auto) check()
  {
    return std::integral_constant<bool, __is_same_as(T, U)
        && decltype(check<U, Args...>())::value>();
  }

template <typename T, typename U, typename... Args>
  concept bool Same()
  {
    return decltype(check<T, U, Args...>())::value;
  }

template <typename... Args>
requires Same<Args...>()
  void foo( Args... args ) {}

int main()
{
  // OK: print "true"
  std::cout << std::boolalpha << Same<int, int, int>() << std::endl;
  // ERROR
  foo(1, 2, 3);
  return 0;
}

$ g++ -std=c++1z test.cpp  -o test

test.cpp:22:41: internal compiler error: tree check: accessed elt 2 of tree_vec
with 1 elts in tsubst, at cp/pt.c:12556
     return decltype(check<T, U, Args...>())::value;
                                         ^

test.cpp:22:41: internal compiler error: Abort trap: 6
g++: internal compiler error: Abort trap: 6 (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


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

* [Bug c++/66091] [c++-concepts] Overloading of member operators based on constraints rejected; regression from r211591
  2015-05-10  3:29 [Bug c++/66091] New: [c++-concepts] Overloading of member operators based on constraints rejected; regression from r211591 tom at honermann dot net
@ 2015-05-12 12:24 ` andrew.n.sutton at gmail dot com
  2015-05-12 20:26 ` tom at honermann dot net
  1 sibling, 0 replies; 3+ messages in thread
From: andrew.n.sutton at gmail dot com @ 2015-05-12 12:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Sutton <andrew.n.sutton at gmail dot com> ---

Confirmed. Fixed in r223061.

When a function declaration started with a non-function declarator, the
requires-clause wasn't being attached to the right declarator object so it
wasn't being added to the declaration.


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

* [Bug c++/66091] [c++-concepts] Overloading of member operators based on constraints rejected; regression from r211591
  2015-05-10  3:29 [Bug c++/66091] New: [c++-concepts] Overloading of member operators based on constraints rejected; regression from r211591 tom at honermann dot net
  2015-05-12 12:24 ` [Bug c++/66091] " andrew.n.sutton at gmail dot com
@ 2015-05-12 20:26 ` tom at honermann dot net
  1 sibling, 0 replies; 3+ messages in thread
From: tom at honermann dot net @ 2015-05-12 20:26 UTC (permalink / raw)
  To: gcc-bugs

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

Tom Honermann <tom at honermann dot net> changed:

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

--- Comment #2 from Tom Honermann <tom at honermann dot net> ---
Thanks!  Confirmed fixed in r223061.


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

end of thread, other threads:[~2015-05-12 20:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-10  3:29 [Bug c++/66091] New: [c++-concepts] Overloading of member operators based on constraints rejected; regression from r211591 tom at honermann dot net
2015-05-12 12:24 ` [Bug c++/66091] " andrew.n.sutton at gmail dot com
2015-05-12 20:26 ` tom at honermann dot net

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