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

             Bug #: 51158
           Summary: C++ std::real() is broken when using -std=c++0x mode
    Classification: Unclassified
           Product: gcc
           Version: 4.4.5
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: libstdc++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: mtall....@gmail.com


Created attachment 25836
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25836
source code demonstrating the bug

With -std=c++0x mode, std::real() from <complex> appears to be broken.

Valid C++ code compiles fine without -std=c++0x mode.

More specifically, with -std=c++0x enabled, std::real() is confused with a user
version of real(), which is in a separate namespace.

In the attached program, the output of the compiled program should be:

A.val = (123,456)
B.val = 123

When using -std=c++0x, the following error occurs during compilation:

real_bug.cpp: In function ‘int main(int, char**)’:
real_bug.cpp:93: error: no match for ‘operator=’ in ‘B = std::real [with _Tp =
mylib::Mat<std::complex<double> >](A)’
real_bug.cpp:52: note: candidates are: mylib::Mat<double>&
mylib::Mat<double>::operator=(const mylib::Mat<double>&)


Note that the compiler wants to call std::real(), while it should be calling
mylib::real() instead.

I'm using gcc 4.4.5 from Scientific Linux 6.1 (a clone of Red Hat Enterprise
Linux 6.1) on an x86_64 machine.  I've also tried clang++ 2.8, and the code
compiles fine.

> gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.5 20110214 (Red Hat 4.4.5-6) (GCC)

Reply via email to