This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/80749] New: [concepts] noexcept specifier operands are allowed but ignored in compound requirements


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

            Bug ID: 80749
           Summary: [concepts] noexcept specifier operands are allowed but
                    ignored in compound requirements
           Product: gcc
           Version: c++-concepts
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tom at honermann dot net
                CC: andrew.n.sutton at gmail dot com, asutton at gcc dot gnu.org
  Target Milestone: ---

It appears that an operand provided to the noexcept specifier in compound
requirements is ignored; the presence of any exception specification appears to
be interpreted as introducing an exception constraint:

$ cat t.cpp
template<typename T>
concept bool C = requires { { T::smf() } noexcept(false); };
struct S1 {
  static void smf();
};
struct S2 {
  static void smf() noexcept;
};
static_assert(C<S1>);
static_assert(C<S2>);

$ g++ --version
g++ (GCC) 8.0.0 20170513 (experimental)
...

$ g++ -c -fconcepts t.cpp
t.cpp:9:1: error: static assertion failed
 static_assert(C<S1>);
 ^~~~~~~~~~~~~

In the above example, the expectation is that the compound requirement having a
'noexcept(false)' specifier will confer no exception constraint requirement and
that both S1 and S2 should satisfy constraint checks.  However, S1 is rejected.

The test case above is ill-formed according to the Concepts TS (N4641) given
that compound requirements are specified to only accept an optional 'noexcept'
specifier (without operands):

§ 5.1.4.3 Compound requirements     [expr.prim.req.compound]
  compound-requirement:
      { expression } noexcept[opt] trailing-return-type[opt] ;

gcc allows an operand to be specified, but appears not to evaluate it.  If the
intent of the TS is to disallow operands to the noexcept specifier in compound
requirements, then gcc should reject them.  Otherwise, if the intent of the TS
is to allow operands, then gcc should evaluate them and conditionally apply
exception constraints (and an issue opened with the Concepts TS).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]