[Bug libstdc++/59087] Issues including complex.h in C++11/1y mode because of C's complex.h

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Oct 3 15:58:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59087

--- Comment #17 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Marc, I've just opened Bug 82417 as rejects-valid but I suppose it's really a
dup of this one. 

(In reply to Marc Glisse from comment #13)
> C++ code has 0 reason to include complex.h, only C code does, and thus it
> makes sense if it contains what C says. We do #undef complex but only
> because we are forced to do it.
> 
> As for boost, reusing the name of a standard C macro is not the best idea
> for interoperability. If you report it to them, I hope they would be fine
> with replacing all 'I' with 'It'.

But the following is valid C++11 code, and our "extension" of including C's
<complex.h> means it doesn't compile:

#include <complex.h>
int I = 0;

Yes, it's silly to do that in C++ and there's a workaround, but it's still a
conformance bug. In strict -std=c++11 mode (rather than -std=gnu++11) this must
compile.


More information about the Gcc-bugs mailing list