valarray defines structs with names like __cos, __sin, etc. It is often the
case (glibc, solaris) that the libc declares functions with those same names.
In the current situation we are lucky because the structs are in namespace std
and the functions in the global namespace. But playing around with namespace
std soon brings something like this:

namespace std {
    double __cos(double);
    struct __cos
    {
        template<typename _Tp>
            _Tp operator()(const _Tp& __t) const;
    };
}
template <class T> struct A {};
int main(){
    A<std::__cos> a;
}

which results in:

error: type/value mismatch at argument 1 in template parameter list for
'template<class T> struct A'
error:   expected a type, got 'std::__cos'
error: invalid type in declaration before ';' token


It would be preferable to use a less conflict-prone name.


-- 
           Summary: valarray uses __cos which may conflict with libm
                    functions
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: marc dot glisse at normalesup dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27340

Reply via email to