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

             Bug #: 51146
           Summary: The name clog for a global variable triggers a
                    segfault inside std::pow
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: alpha...@hotmail.com


Adding a global variable to the code with a name like clog, while using
std::pow on a std::complex<double> triggers a segfault when std::pow is
reached. A simple example ( http://codepad.org/4Ekpgj91 ):

#include <iostream>
#include <complex>
#include <cmath>

int clog=0;

int main()
{
    std::cout<<"test1"<<std::endl;
    std::complex<double> b(1,-1);
    std::cout<<"test "<<std::pow(b,2.0)<<std::endl;
    std::cout<<"test2"<<std::endl;
}

This behavior has first been noticed on MinGW with gcc 4.5.2, but as soon as I
found out where the bug came from it was checked on codepad, and from various
gcc users in irc.freenode.net . I rate this bug as major because there might be
something deeper behind it.

Reply via email to