C++ Logo

std-discussion

Advanced search

Re: atomic constraint rules vs requires-clause rules

From: mauro russo <ing.russomauro_at_[hidden]>
Date: Tue, 25 Feb 2025 01:45:09 +0100
About first question, I have inserted the core issue
https://github.com/cplusplus/CWG/issues/675

Let me now move to the second original question:

it is related to the different perspective provided by the two clauses
[expr.prim.req.general] - p5
and
[temp.res.general]-p6+p(6.4)

for the case when an invalid type/expression always happens,
regardless of the template argument inolved in the substitution.

Indeed, for the requires-expression, the former clause reads:
*If the substitution of template arguments into a requirement would always
result in a substitution failure, the program is ill-formed; no diagnostic
required.*

and the latter read:
*The program is ill-formed, no diagnostic required, if*
*...*
*- any constraint-expression in the program, introduced or otherwise, has
(in its normal form) an atomic constraint A where no satisfaction check of
A could be well-formed and no satisfaction check of A is performed*


The point is: for a requires-expression that case is always IFNDR,
whereas for a constraint-expression it reads that IFNDR is in place
only if no satisfation check is actually performed.

I don't see what is the rationale behind it.
It would make sense only for errors that are not in the
immediate context, because in this case a satisfation
check leads to an ill-formed notification by compilers.
However, if the error that causes the lack of satisfaction
is in the immediate context, then the constraint is just
not satisfied (based on [temp.constr.atomic]-p3), and I don't
see any motivation not to fall in IFNDR.

Let me also additionally notice that [temp.res.general]-p6+p(6.4)
does not indicate any difference between templated or non-templated
entities, whereas [expr.prim.req.general] - p5 better clarifies that
an always-false expression in a non-templated entity is IF instead
of IFNDR.
Even in this perspective, [temp.res.general]-p6+p(6.4) is
more relaxed as it requires IFNDR, not IF (for non-templated entities).

Received on 2025-02-25 00:45:23