g++4.9.2 fails to compile standard C++11 code

Roger Wells ROGER.K.WELLS@leidos.com
Thu Mar 12 14:54:00 GMT 2015


On 03/11/2015 06:55 PM, Vlad Gheorghiu wrote:
> The following code fails to compile under latest cygwin, Windows 7,
> g++4.9.2. Compiled with g++ -std=c++11 test.cpp. The compiler
> complains that std::log2 is not a member of std.
>
>      #include <cmath>
>      #include <iostream>
>
>      int main()
>      {
>              auto x = std::log2(10);
>              std::cout << x << std::endl;
>      }
>
>
> Verbatim error:
>
>      g++ -std=c++11 test.cpp
>      test.cpp: In function ‘int main()’:
>      test.cpp:5:11: error: ‘log2’ is not a member of ‘std’
>        auto x = std::log2(10);
>                 ^
>      test.cpp:5:11: note: suggested alternative:
>      In file included from
> /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/cmath:44:0,
>                       from test.cpp:1:
>      /usr/include/math.h:305:15: note:   ‘log2’
>       extern double log2 _PARAMS((double));
>
FWIW
I get the same error on cygwin64 gcc 4.9.2
but
it is fine on:
Linux, gcc 4.9.2 (Fedora 21)
MinGW, 32 bit, gcc 4.7.0 (Windows 7)
MinGW, 64 bit, gcc 4.9.0 (Windows 7)

HTH


-- 
Roger Wells, P.E.
leidos
221 Third St
Newport, RI 02840
401-847-4210 (voice)
401-849-1585 (fax)
roger.k.wells@leidos.com


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list