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

            Bug ID: 65575
           Summary: [c++-concepts] Parse error for requires clause on
                    functions that return a reference type
           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

Encountered with the latest revision of the gcc c++-concepts branch (r221681). 
Parse errors are issued for function declarations that specify a requires
clause and return a reference type.  The parse error occurs whether the
function return type is specifed with a trailing return type or not.  The error
occurs for member functions as well as non-member functions.

A test case follows.  Changing the return type of f() from int& to just int
avoids the error.  Replacing the return type with a type alias for int& also
avoids the problem.

$ svn info   # From my local svn gcc repo.
Path: .
URL: svn://gcc.gnu.org/svn/gcc/branches/c++-concepts
Repository Root: svn://gcc.gnu.org/svn/gcc
Repository UUID: 138bc75d-0d04-0410-961f-82ee72b054a4
Revision: 221681
Node Kind: directory
Schedule: normal
Last Changed Author: asutton
Last Changed Rev: 221669
Last Changed Date: 2015-03-25 14:07:42 -0400 (Wed, 25 Mar 2015)

$ cat t.cpp 
template<typename T>
concept bool C = true;
auto f() -> int& requires C<int>;

$ g++ -c -std=c++1z t.cpp
t.cpp:3:16: error: requires clause after non-function declaration
 auto f() -> int& requires C<int>;
                ^

Reply via email to