libc++ problem with <complex> and integers

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:

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...

The behavior for int is unspecified. 26.4 [complex.numbers]/p2 says:

The effect of instantiating the template complex for any type other than float, double, or long double is unspecified.

We could support it as an extension. However this would be an extension that I do not believe the C++ committee will ever adopt. Standardizing complex<integral> has been discussed on the committee off and on for over a decade and there exists significant resistance from at least one vendor for supporting it.

Howard