public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/54112] New: including complex.h and complex fails in C++03
@ 2012-07-28  7:57 glisse at gcc dot gnu.org
  2012-07-28 10:11 ` [Bug libstdc++/54112] " paolo.carlini at oracle dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: glisse at gcc dot gnu.org @ 2012-07-28  7:57 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54112

             Bug #: 54112
           Summary: including complex.h and complex fails in C++03
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: glisse@gcc.gnu.org


#include <complex.h>
#ifdef FIX
#undef complex
#endif
#include <complex>

fails to compile with glibc. Since libstdc++ already installs a complex.h
wrapper that #include_next complex.h, I guess it could easily #undef complex
afterwards.

Note that you can include tr1/complex instead of complex if you prefer.

I guess I could also ask glibc to protect their #define with #ifndef
__cplusplus.

It is strange that in C++11 it is impossible to have access to the C99
functions cacos and others, since C++11 hijacks their header. g++ accepts
_Complex, I expect we should still have access to those functions.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/54112] including complex.h and complex fails in C++03
  2012-07-28  7:57 [Bug libstdc++/54112] New: including complex.h and complex fails in C++03 glisse at gcc dot gnu.org
@ 2012-07-28 10:11 ` paolo.carlini at oracle dot com
  2012-07-28 10:27 ` glisse at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-07-28 10:11 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54112

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-07-28 10:11:04 UTC ---
Why it happens only in C++03 mode? I'm asking because if the issue isn't a
regression and we are sure that it doesn't happen in C++11 mode, I don't think
it can be considered high priority.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/54112] including complex.h and complex fails in C++03
  2012-07-28  7:57 [Bug libstdc++/54112] New: including complex.h and complex fails in C++03 glisse at gcc dot gnu.org
  2012-07-28 10:11 ` [Bug libstdc++/54112] " paolo.carlini at oracle dot com
@ 2012-07-28 10:27 ` glisse at gcc dot gnu.org
  2012-07-28 10:50 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: glisse at gcc dot gnu.org @ 2012-07-28 10:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54112

--- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> 2012-07-28 10:26:42 UTC ---
(In reply to comment #1)
> Why it happens only in C++03 mode?

Because the complex.h wrapper distributed with libstdc++ does:

#ifdef __GXX_EXPERIMENTAL_CXX0X__
# include <ccomplex>
#else
# if _GLIBCXX_HAVE_COMPLEX_H
#  include_next <complex.h>
# endif
#endif

That's what I meant by "hijack", the system's complex.h can never be included
in C++11.

> I'm asking because if the issue isn't a
> regression and we are sure that it doesn't happen in C++11 mode, I don't think
> it can be considered high priority.

I am not saying it is high priority (on the other hand, it is rather easy).
Note that there are 2 issues (I should have been clearer):

1) we can't include both complex.h and complex in C++03 mode. The fix is
trivial, #undef complex after the #include_next quoted above. The other headers
all have a long list of #undef, that's just one more.

2) In C++11, there is no way to have cacos declared. A solution would be to
move the _GLIBCXX_HAVE_COMPLEX_H block outside of the
__GXX_EXPERIMENTAL_CXX0X__ condition.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/54112] including complex.h and complex fails in C++03
  2012-07-28  7:57 [Bug libstdc++/54112] New: including complex.h and complex fails in C++03 glisse at gcc dot gnu.org
  2012-07-28 10:11 ` [Bug libstdc++/54112] " paolo.carlini at oracle dot com
  2012-07-28 10:27 ` glisse at gcc dot gnu.org
@ 2012-07-28 10:50 ` paolo.carlini at oracle dot com
  2012-08-13 11:55 ` glisse at gcc dot gnu.org
  2012-08-13 11:58 ` glisse at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-07-28 10:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54112

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-07-28 10:50:15 UTC ---
Sure, sure. I'm still thinking that unless we have a regression, the less we do
for C++03 mode, the better. But if you can already see simple enough fixes for
both issues you are welcome to post them to the mailing list!

PS: to be honest, I can't remember at the moment to have written the
"hijacking", which seems indeed a little weird now. Maybe some svn blame is in
order ;)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/54112] including complex.h and complex fails in C++03
  2012-07-28  7:57 [Bug libstdc++/54112] New: including complex.h and complex fails in C++03 glisse at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-07-28 10:50 ` paolo.carlini at oracle dot com
@ 2012-08-13 11:55 ` glisse at gcc dot gnu.org
  2012-08-13 11:58 ` glisse at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: glisse at gcc dot gnu.org @ 2012-08-13 11:55 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54112

--- Comment #4 from Marc Glisse <glisse at gcc dot gnu.org> 2012-08-13 11:55:04 UTC ---
Author: glisse
Date: Mon Aug 13 11:55:00 2012
New Revision: 190340

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190340
Log:
2012-08-13  Marc Glisse  <marc.glisse@inria.fr>

    PR libstdc++/54112
    * include/c_compatibility/complex.h: Undefine complex, always
    include system's complex.h if present.
    * testsuite/26_numerics/complex/c99.cc: New testcase.
    * testsuite/17_intro/headers/c++1998/complex.cc: Likewise.
    * doc/xml/manual/numerics.xml: Document it.

Added:
    trunk/libstdc++-v3/testsuite/17_intro/headers/c++1998/complex.cc   (with
props)
    trunk/libstdc++-v3/testsuite/26_numerics/complex/c99.cc   (with props)
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/doc/xml/manual/numerics.xml
    trunk/libstdc++-v3/include/c_compatibility/complex.h

Propchange: trunk/libstdc++-v3/testsuite/17_intro/headers/c++1998/complex.cc
            ('svn:eol-style' added)

Propchange: trunk/libstdc++-v3/testsuite/17_intro/headers/c++1998/complex.cc
            ('svn:keywords' added)

Propchange: trunk/libstdc++-v3/testsuite/26_numerics/complex/c99.cc
            ('svn:eol-style' added)

Propchange: trunk/libstdc++-v3/testsuite/26_numerics/complex/c99.cc
            ('svn:keywords' added)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/54112] including complex.h and complex fails in C++03
  2012-07-28  7:57 [Bug libstdc++/54112] New: including complex.h and complex fails in C++03 glisse at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2012-08-13 11:55 ` glisse at gcc dot gnu.org
@ 2012-08-13 11:58 ` glisse at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: glisse at gcc dot gnu.org @ 2012-08-13 11:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54112

Marc Glisse <glisse at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #5 from Marc Glisse <glisse at gcc dot gnu.org> 2012-08-13 11:58:29 UTC ---
Fixed.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-08-13 11:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-28  7:57 [Bug libstdc++/54112] New: including complex.h and complex fails in C++03 glisse at gcc dot gnu.org
2012-07-28 10:11 ` [Bug libstdc++/54112] " paolo.carlini at oracle dot com
2012-07-28 10:27 ` glisse at gcc dot gnu.org
2012-07-28 10:50 ` paolo.carlini at oracle dot com
2012-08-13 11:55 ` glisse at gcc dot gnu.org
2012-08-13 11:58 ` glisse at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).