<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58672>58672</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Scope must be considered when a concept is evaluated (as an expression).
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
oberdorc
</td>
</tr>
</table>
<pre>
First, I am not an expert on interpreting the C++ standard. However, I believe that the former result seen in GCC should be the correct one - so after the 'fix' it became wrong?!
Let me argue on this: Purpose of the applied concept constraint is to verify that a certain member function is present and can be invoked (from the current scope). So for Foo_1, it is expected to evaluate to false in all cases. The same is true for Foo_3/Foo_4 as we look for a public member function and the evaluation result is true in all cases. Critical is the case with Foo_3: private member but with class Pred as a friend. The evalution from within Pred should pass as it is a friend. In all other cases, however, this should fail. After the fix in gcc trunk the concept now always evaluates to true although the respective function cannot be seen nor acceesed from outside scope.
The standard says the following (13.7.9 Concept Definitions, paragraph 5):
"A concept is not instantiated ([[temp.spec]](https://eel.is/c++draft/temp.spec))[.](https://eel.is/c++draft/temp.concept#5.sentence-1)
[Note [1](https://eel.is/c++draft/temp.concept#note-1): A concept-id ([[temp.names]](https://eel.is/c++draft/temp.names)) is evaluated as an expression[.](https://eel.is/c++draft/temp.concept#5.sentence-2)
A concept cannot be explicitly instantiated ([[temp.explicit]](https://eel.is/c++draft/temp.explicit)), explicitly specialized ([[temp.expl.spec]](https://eel.is/c++draft/temp.expl.spec)), or partially specialized ([[temp.spec.partial]](https://eel.is/c++draft/temp.spec.partial))[.](https://eel.is/c++draft/temp.concept#5.sentence-3)
— end note]"
>From this, I conclude that the concept needs to be evaluated ("as an expression") whenever and wherever it occurs at compile-time. So, within the assignment in the definition of Pred I would expect that the current scope matters (which is that of Pred and access to Foo_2 is permitted considering friendship). Later "visible" shall be reevaluted in the scope of the main function and should therefore return a different result.
So this is my take on the matter: The current answer is wrong for both gcc and clang and the real issue has not been solved despite that the inconstency between gcc/clang was resolved. Behavior should be like before with gcc-10.4!
_Originally posted by @oberdorc in https://github.com/llvm/llvm-project/issues/52816#issuecomment-1272316577_
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVtuO2zYQ_Rr5hbBg0fcHP-yl2wYI2gDJ-4KSxha7lCiQlJ3t1_cMKV82KQJ0k4VgLUXOlWfmTGnr150Y_5608yGTD-KDUK3obBCqE_S1JxeE7YTuArneUdDdQYSGxEMm7_EIH1RXK1fn4g97oiO5pKMko7HCURXi-b11LTnhyA8mCE_EOsXvDw_CN3YwNSTiuco6RxXbJDEV3gq1h-W4lcn1Xn_Fr9ABxyvVkjg52x2y-VMmi2z2mM3u0u9HCgK7yh0GYvdDo302vxOfBtdbj0_7qFH1PdysYbSrqA_89sEpBCu0F8EKxKP3rykKJSokA5vQ3JbwaT90VdCcHC-QGk8dJw3akDlEo7ujfYHyTG72zrYpugHR4ZivbE-Z3Obis-XUiCdrnwtOnY6mOfFVgDB8oKMygwrE_--V8axZKGNgx5PPxRfo9ZwLdtkNdNE3z-QTvxdCeXEiYax9iZtK9ENpdPVdIOw9uzma5E_jhZ11vzX94HTQlTJxm8PDZ3HSoRntI-O900d2fjRVDiEdqIzyXnxyiBHeKbF3mro6RRPNR-sxcXweduPZESw9C0MuZesq_SG5Z-GMS05yTpsrMhkIZyV7pU0u7i74ArgEB3ioKg62exkBmbDR2RN0n9Srv9xIhEhMizIBOg9NlEDK-PY04H_JLDDBNQVYROh3fAtVRQBNnYK0Q_C6poSM_BbL8X7HKsNFv_qxnoyxJ65G4KuY5-t8Kx5GVx9przvNdmP4vXLq4FTfiCUgx5cyqpfy7hIe0sIO6o5NBa1CQm62vMcTqO1zDipbPvIjN00IPVcUIIaHyOQoMPlUpa5QO1Qtllc52MWzvM__t_joYCbny5xLjLCcFqwtBbG8_9MCX3gXP6EbsY9akZ5LVqb62yR0KDT_niwkwZiGWOAjhBL6Y6cFbDyu7NclSV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