Comeau online compiler and std::sqrt

This is a discussion on Comeau online compiler and std::sqrt within the C++ Programming forums, part of the General Programming Boards category; I would like an opinion concerning this program: Code: #include <cmath> int main() { double x = 0.0; x = ...

  1. #1
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,915

    Comeau online compiler and std::sqrt

    I would like an opinion concerning this program:
    Code:
    #include <cmath>
    
    int main()
    {
        double x = 0.0;
        x = std::sqrt(x);
    }
    The MinGW port of g++ 3.4.5 finds no fault with the above program. The Comeau online compiler, on the other hand, fails to compile it, citing this error:
    Code:
    MODE:strict errors C++ C++0x_extensions
    
    "ComeauTest.c", line 6: error: more than one instance of overloaded function
              "std::sqrt" matches the argument list, the choices that match are:
                function "std::sqrt(float)"
                function "std::sqrt(long double)"
                The argument types that you used are: (double)
          x = std::sqrt(x);
              ^
    
    1 error detected in the compilation of "ComeauTest.c".
    Checking the C++ Standard, I see:
    Quote Originally Posted by C++03 Section 26.5 Paragraph 5
    In addition to the double versions of the math functions in <cmath>, C++ adds float and long double overloaded versions of these functions, with the same semantics.
    I conclude then that the error is due to a missing double sqrt(double) version of std::sqrt, and thus is a bug in the standard library implementation used by the Comeau online compiler. Am I correct?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    You are correct.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21