[Bug libstdc++/82417] Macros from defined in C++11
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82417 Jonathan Wakely changed: What|Removed |Added Status|ASSIGNED|RESOLVED See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=82503 Resolution|--- |FIXED Target Milestone|--- |8.0 --- Comment #6 from Jonathan Wakely --- Fixed on trunk. Bug 82503 opened for the request to add a warning.
[Bug libstdc++/82417] Macros from defined in C++11
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82417 --- Comment #5 from Jonathan Wakely --- Author: redi Date: Tue Oct 10 11:25:45 2017 New Revision: 253581 URL: https://gcc.gnu.org/viewcvs?rev=253581=gcc=rev Log: PR libstdc++/82417 do not include C99 in strict modes As an extension the C++ version of includes the C version, but that defines macros with non-reserved names that should not be defined in ISO C++. Only include the C header for non-strict modes, or for pre-C++11 (because C++98 doesn't mention at all). PR libstdc++/59087 PR libstdc++/82417 * include/c_compatibility/complex.h [!C++98 && __STRICT_ANSI__]: Do not include C library's . * testsuite/26_numerics/complex/c99.cc: Depend on __STRICT_ANSI__. * testsuite/26_numerics/headers/complex.h/std_c++11.h: New test. * testsuite/26_numerics/headers/complex.h/std_gnu++11.h: New test. * testsuite/26_numerics/headers/complex.h/std_c++98.h: New test. Added: trunk/libstdc++-v3/testsuite/26_numerics/headers/complex.h/ trunk/libstdc++-v3/testsuite/26_numerics/headers/complex.h/std_c++11.h - copied, changed from r253550, trunk/libstdc++-v3/testsuite/26_numerics/complex/c99.cc trunk/libstdc++-v3/testsuite/26_numerics/headers/complex.h/std_c++98.h - copied, changed from r253550, trunk/libstdc++-v3/testsuite/26_numerics/complex/c99.cc trunk/libstdc++-v3/testsuite/26_numerics/headers/complex.h/std_gnu++11.h - copied, changed from r253550, trunk/libstdc++-v3/testsuite/26_numerics/complex/c99.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/c_compatibility/complex.h trunk/libstdc++-v3/testsuite/26_numerics/complex/c99.cc
[Bug libstdc++/82417] Macros from defined in C++11
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82417 --- Comment #4 from Jonathan Wakely --- I'm not opposed to a warning in principle, but I'd prefer it to be one controllable by a -Wxxx option. I don't know how to do that using the preprocessor, so we'd have to do something like: #ifndef _GLIBCXX_NO_CCOMPLEX_WARNING # warning "Including makes no sense. Define _GLIBCXX_NO_CCOMPLEX_WARNING to disable this warning." #endif And that is a bit ugly.
[Bug libstdc++/82417] Macros from defined in C++11
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82417 --- Comment #3 from Marc Glisse --- (In reply to Jonathan Wakely from comment #2) > Thinking about this further, I think we must not include at all > for strict -std=c++1* modes, Yes. Can we get a #warning in that case which explains that including in strict C++11+ mode makes no sense? Actually, could also do with a #warning explaining that it never makes sense to include it.
[Bug libstdc++/82417] Macros from defined in C++11
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82417 Jonathan Wakely 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 --- Thinking about this further, I think we must not include 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 std::complex n{0, I}; double zero = n.imaginary(); This explodes horribly. We can't just #undef the names after including because the user macros will already have been trashed by then.
[Bug libstdc++/82417] Macros from defined in C++11
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82417 --- Comment #1 from Marc Glisse --- (In reply to Jonathan Wakely from comment #0) > The C++11 standard says that should just include the C++ > header and completely ignore the C library's header. I am very surprised that nobody has cared enough to get the standard fixed. But I can't complain, I didn't write a proposal either. > For C++11 mode we should #undef the macros that defines with > non-reserved names, and maybe consider not including at all for > -std=c++1* modes. I guess so.
[Bug libstdc++/82417] Macros from defined in C++11
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82417 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2017-10-03 See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=56111 Ever confirmed|0 |1