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

             Bug #: 53429
           Summary: complex::{imag,real} should be marked alwaysinline to
                    guarantee libstdc++ binary compatibility between C++98
                    and C++11
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: jyass...@gcc.gnu.org


The non-const overloads of std::complex::real and std::complex::imag go from
returning _Tp& to _Tp in C++98 vs C++11:
http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/include/std/complex?view=markup.
 libstdc++ includes explicit instantiations of operator<< and operator>> with
complex arguments:
http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/src/c%2B%2B98/complex_io.cc?view=markup.
These operator<< and operator>> overloads call complex::real() and
complex::imag(). If those calls are inlined (which is likely), so that no weak
definition of real() and imag() is exposed to users of the library, then I
believe all is well. However, if the compiler decides not to inline them, then
people linking libstdc++ from the other version of the language may wind up
with two conflicting weak definitions of the symbols.

I think marking them as alwaysinline would guarantee compatibility.

Reply via email to