[Bug 218657] Usage of I (_Complex_I) from complex.h results in unexpected warnings with clang -pedantic
[email protected] Sun, 24 May 2026 23:32:11 +0000
| Newsgroups | gmane.os.freebsd.devel.standards |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D218657 Mark Millard <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #2 from Mark Millard <[email protected]> --- (In reply to Andrey Alexeyev from comment #0) As main [so: 16] is now llvm 21 based, retesting for c99, c11, c23, and c2y follows. The messages show that, as stands for this context, the notation 1.0i still ends up in use and is reported for c99 .. C23 but not for c2y. It now says "C2y" instead of "GNU" in front of "extension" when it is reported. Also: -Wc2y-extensions vs. -Wgnu-imaginary-constant # cat complexI.c=20 // clang -std=3Dc11 -pedantic complexI.c // ./a.out // #include <stdio.h> #include <complex.h> int main(void) { complex double c =3D 1.0 + 2.0 * I; printf("c =3D %f+%fi\n", creal(c), cimag(c)); return 0; } # clang -std=3Dc99 -pedantic complexI.c complexI.c:12:36: warning: imaginary constants are a C2y extension [-Wc2y-extensions] 12 | complex double c =3D 1.0 + 2.0 * I; | ^ /usr/include/complex.h:47:12: note: expanded from macro 'I' 47 | #define I _Complex_I | ^ /usr/include/complex.h:38:37: note: expanded from macro '_Complex_I' 38 | #define _Complex_I ((float _Complex)1.0i) | ^ 1 warning generated. # clang -std=3Dc11 -pedantic complexI.c complexI.c:8:36: warning: imaginary constants are a C2y extension [-Wc2y-extensions] 8 | complex double c =3D 1.0 + 2.0 * I; | ^ /usr/include/complex.h:47:12: note: expanded from macro 'I' 47 | #define I _Complex_I | ^ /usr/include/complex.h:38:37: note: expanded from macro '_Complex_I' 38 | #define _Complex_I ((float _Complex)1.0i) | ^ 1 warning generated. # ./a.out c =3D 1.000000+2.000000i # clang -std=3Dc23 -pedantic complexI.c complexI.c:12:36: warning: imaginary constants are a C2y extension [-Wc2y-extensions] 12 | complex double c =3D 1.0 + 2.0 * I; | ^ /usr/include/complex.h:47:12: note: expanded from macro 'I' 47 | #define I _Complex_I | ^ /usr/include/complex.h:38:37: note: expanded from macro '_Complex_I' 38 | #define _Complex_I ((float _Complex)1.0i) | ^ 1 warning generated. # clang -std=3Dc2y -pedantic complexI.c #=20 (So -std=3Dc2y does not complain.) --=20 You are receiving this mail because: You are the assignee for the bug.=