[Bug libstdc++/82417] New: Macros from <complex.h> defined in C++11
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Oct 3 15:47:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82417
Bug ID: 82417
Summary: Macros from <complex.h> defined in C++11
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
The C++11 standard says that <complex.h> should just include the C++ <complex>
header and completely ignore the C library's header. We take some liberty and
include _both_ C++'s <complex> and C's <complex.h>, because historically
<complex.h> wasn't part of the C++ standard and so including it used the C
version and worked OK.
However this means that the following valid C++11 code is rejected:
#include <complex.h>
std::complex<double> I{0, 1};
In file included from /usr/include/c++/7/complex.h:36:0,
from I.cc:1:
I.cc:3:22: error: expected unqualified-id before ‘__extension__’
std::complex<double> I{0, 1};
^
I.cc:3:22: error: expected ‘)’ before ‘__extension__’
For C++11 mode we should #undef the macros that <complex.h> defines with
non-reserved names, and maybe consider not including <complex.h> at all for
-std=c++1* modes.
More information about the Gcc-bugs
mailing list