-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[C++20] [Modules] Including <valarray> in GMF in front of other headers may violate ODR Checking #61643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@llvm/issue-subscribers-clang-modules |
Agreed I noticed this in both libc++ and libstdc++ using the reproducer in #61642. Commenting out the 3 I have not checked the Standard what the required behaviour should be. I wonder whether the same issue can occur with the global |
While we need to check the standard to know what is the "correct" thing, I believe the |
While I am not familiar with standard library, I feel like the implementation is not the same with the standard: The standard says: template<class T> valarray<bool> operator&&(const valarray<T>&, const valarray<T>&);
template<class T> valarray<bool> operator&&(const valarray<T>&,
const typename valarray<T>::value_type&);
template<class T> valarray<bool> operator&&(const typename valarray<T>::value_type&,
const valarray<T>&); And the libcxx implement it like: template<class _Expr1, class _Expr2>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
__val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
>::type
operator&&(const _Expr1& __x, const _Expr2& __y) { ... }
template<class _Expr>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
__is_val_expr<_Expr>::value,
__val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
_Expr, __scalar_expr<typename _Expr::value_type> > >
>::type
operator&&(const _Expr& __x, const typename _Expr::value_type& __y) { ... }
template<class _Expr>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
__is_val_expr<_Expr>::value,
__val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
__scalar_expr<typename _Expr::value_type>, _Expr> >
>::type
operator&&(const typename _Expr::value_type& __x, const _Expr& __y) { ... } I feel like the libcxx's implementations is more relax than the spec. |
I tried with a simpler In libc++ most declarations are in the inline namespace
Note that |
I am not sure if I misunderstand this. But this issue is about I feel like #61912 is a real compiler bug from the diagnostic message. |
ah yes sorry I looked at the wrong operator. |
We meet the problem twice now (#61642 and #61150) so it may make sense to create a summary issue for this to avoid wider confusion.
Here is the reproducer:
Compile it with:
(
STL_PATH
refer to libcxx HEAD in my reproducer). And it gives error diagnostics:According to my analysis, this is caused by the free standing operators in
<valarray>
affected the operator in the require clause. We can find the example in #61150. And the compilation completes after I remove the free standing operator in valarray. Here is the example: https://reviews.llvm.org/D146695Although I add the libcxx tag, I am not sure that this is libcxx bug. I just add it to CC the libcxx folks. Since I met this in libstdc++ too. Maybe this is a defect in the spec.
The text was updated successfully, but these errors were encountered: