https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95592
Bug ID: 95592 Summary: Collision with struct _Cosh when Cross compiling libstdc++ Product: gcc Version: 8.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: kevin at arilabs dot net Target Milestone: --- I am cross compiling gcc 8.3.0 for QNX 6.6. While doing so, libstdc++-v3/include/bits/valarray_after.h was having trouble with "struct _Cosh" defined in valarray_before.h because it was colliding with the function _Cosh() is defined in one of the target OS's headers. Specifically it was having trouble with (around line 445 of valarray_after.h): _DEFINE_EXPR_UNARY_FUNCTION(cosh, _Cosh) The compiler was using the function declaration of _Cosh instead of struct _Cosh. There were other _DEFINE_EXPR_UNARY_FUNCTION that had the same issue (I don't remember which ones as I focused on _Cosh). Below is a patch to valarray_after.h that fixes the issue. I'm pretty sure QNX may be the only target OS with this problem, so I am content if this doesn't make it in gcc, but thought that perhaps removing ambiguity from the preceding template definitions wouldn't be bad. I took a look at gcc 9 and 10 code base and the issue appears to exist there as well. Thanks Kevin Index: libstdc++-v3/include/bits/valarray_after.h =================================================================== --- libstdc++-v3/include/bits/valarray_after.h (revision 1469) +++ libstdc++-v3/include/bits/valarray_after.h (working copy) @@ -422,20 +422,20 @@ #define _DEFINE_EXPR_UNARY_FUNCTION(_Name, _UName) \ template<class _Dom> \ - inline _Expr<_UnClos<_UName, _Expr, _Dom>, \ + inline _Expr<_UnClos<struct _UName, _Expr, _Dom>, \ typename _Dom::value_type> \ _Name(const _Expr<_Dom, typename _Dom::value_type>& __e) \ { \ typedef typename _Dom::value_type _Tp; \ - typedef _UnClos<_UName, _Expr, _Dom> _Closure; \ + typedef _UnClos<struct _UName, _Expr, _Dom> _Closure; \ return _Expr<_Closure, _Tp>(_Closure(__e())); \ } \ \ template<typename _Tp> \ - inline _Expr<_UnClos<_UName, _ValArray, _Tp>, _Tp> \ + inline _Expr<_UnClos<struct _UName, _ValArray, _Tp>, _Tp> \ _Name(const valarray<_Tp>& __v) \ { \ - typedef _UnClos<_UName, _ValArray, _Tp> _Closure; \ + typedef _UnClos<struct _UName, _ValArray, _Tp> _Closure; \ return _Expr<_Closure, _Tp>(_Closure(__v)); \ }