[Bug libstdc++/82417] Macros from <complex.h> defined in C++11
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Oct 3 16:06:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82417
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Thinking about this further, I think we must not include <complex.h> at all for
strict -std=c++1* modes, because users could have defined their own macros with
those names, but the C header #undefs them and then redefines them with
different meaning:
#define I 1
#define imaginary imag
#include <complex.h>
std::complex<double> n{0, I};
double zero = n.imaginary();
This explodes horribly.
We can't just #undef the names after including <complex.h> because the user
macros will already have been trashed by then.
More information about the Gcc-bugs
mailing list