[cfe-dev] libc++ problem with <complex> and integers

Sean McBride sean at rogue-research.com
Wed Mar 28 15:32:24 PDT 2012


Hi all,

Are libc++ questions on-topic here?  The project's website links to this list, so...

The following code compiles on many compilers on many OSes (it's a reduced test case), but if use clang with -stdlib=libc++ I get an error:

---------
#include <complex>

typedef int ComponentType; // Note int, not double!
typedef std::complex<ComponentType> TargetType;
static ComponentType Function(const TargetType& pixel) {                                                                    
    return std::norm(pixel);                                             
}                                                                    
---------

/usr/include/c++/v1/complex:931:9: error: no matching function for call to 'isinf'
    if (isinf(__c.real()))
        ^~~~~
/Volumes/Leopard/Users/sean/Downloads/repro.cpp:6:12: note: in instantiation of function template specialization 'std::__1::norm<int>' requested here
    return std::norm(pixel);                                             
           ^
/usr/include/c++/v1/cmath:728:1: note: candidate template ignored: substitution failure [with _A1 = int]
isinf(_A1 __x)
^

If I change ComponentType to a float or double all is well.  (I'm using the libc++ that comes with Xcode 4.3.1.)  Is this a libc++ bug?  (I saw nothing related in the bugbase.)  If so, I'll file...

Thanks,

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada






More information about the cfe-dev mailing list