You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: npy_math.h complex accessors call UCRT creal/cimag, but npy_cdouble is C99 _Complex for icx on Windows #32482
Since gh-31389 (fix for gh-31337), npy_common.h excludes __INTEL_LLVM_COMPILER from
the _MSC_VER branch, so for icx on Windows npy_cdouble is double _Complex rather
than _Dcomplex:
Windows UCRT declares creal(_Dcomplex), crealf(_Fcomplex), creall(_Lcomplex)
regardless of which frontend compiles it, since it is the same CRT. So the two
headers disagree and including <numpy/npy_math.h> alone fails to compile.
Note the __cplusplus path already avoids the UCRT call by using z._Val[0]; only the
C path is affected.
Suggested fix: use real/imag (or z._Val[0]) instead of UCRT creal/cimag when
_MSC_VER is defined, or do not switch the typedefs based on the CRT at all.
Compiling with -U__INTEL_LLVM_COMPILER makes it build again, which confirms the
typedef selection is the trigger.
This is a different failure location than gh-31337 - that one was numpy's own
meson.build _Fcomplex type check; this one is npy_math.h and affects downstream
projects using the installed headers.
Thanks for the report @vchamarthi. I see the problem - the current treatment in the header cannot be correct for both of:
Compile NumPy with MSVC, then a package depending on it with Intel compilers
Compile both NumPy and a package depending on it with Intel compilers
Suggested fix: use real/imag (or z._Val[0]) instead of UCRT creal/cimag when _MSC_VER is defined, or do not switch the typedefs based on the CRT at all.
I'll have a closer look, but I think the latter approach is preferred.
This complex type handling is still a mess, with multiple related issues. There's the immediate compile error above, there's a NumPy-internal C/C++ mix mess, and there's an ABI part (xref gh-20880 yet again).
I did an audit with Claude, and there are a number of inconsistencies in how complex types are defined (line numbers as of commit fc5a53a):
So NumPy built with icx is already internally inconsistent today: it applies a struct brace-initializer to a _Complex typedef, and only compiles because clang accepts that as an extension.
I think we need a small fix that's back-portable (restoring the 2.4.4 behavior in npy_common.h), and a larger fix to clean up more of this, getting rid of all these inconsistent defines. The meson.build part of gh-31389 should be kept it looks like.
Activity
rgommers commentedon Sep 3, 2026
Thanks for the report @vchamarthi. I see the problem - the current treatment in the header cannot be correct for both of:
I'll have a closer look, but I think the latter approach is preferred.
rgommers commentedon Sep 3, 2026
This complex type handling is still a mess, with multiple related issues. There's the immediate compile error above, there's a NumPy-internal C/C++ mix mess, and there's an ABI part (xref gh-20880 yet again).
I did an audit with Claude, and there are a number of inconsistencies in how complex types are defined (line numbers as of commit fc5a53a):
icx-clgetsnumpy/_core/include/numpy/npy_common.h:395_MSC_VER && !__INTEL_COMPILER && !__INTEL_LLVM_COMPILERdouble _Complexnumpy/_core/src/npymath/npy_math_complex.c.src:68_MSC_VER && !__INTEL_COMPILER{1.0, 0.0}brace initnumpy/_core/feature_detection_cmath.h:11_MSC_VER && !__INTEL_COMPILER_Complextypedefsnumpy/_core/meson.build:183cc.get_id() in {msvc, clang-cl}sizeofbranchSo NumPy built with
icxis already internally inconsistent today: it applies a struct brace-initializer to a_Complextypedef, and only compiles because clang accepts that as an extension.I think we need a small fix that's back-portable (restoring the 2.4.4 behavior in
npy_common.h), and a larger fix to clean up more of this, getting rid of all these inconsistent defines. Themeson.buildpart of gh-31389 should be kept it looks like.