This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/82417] Macros from <complex.h> defined in C++11


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]