This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Corinna Vinschen wrote:
On Mar 13 09:13, Csaba Raduly wrote:
Hi

On Thu, Mar 12, 2015 at 10:55 AM, Duncan Roe  wrote:
On Wed, Mar 11, 2015 at 06:55:16PM -0400, 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, this program works fine under Linux / gcc4.8.2:
ISTR a discussion about some C++11 features being configured away due
to Cygwin's lack of some C library functions ("to_string not a member
of std"): https://sourceware.org/ml/cygwin/2015-01/msg00245.html

Your issue may be related (I'm guessing here because I don't have
Cygwin at hand right now).
I guess the same.  The problem is probably related to the fact that
newlib is still missing most of the long double functions (cosl, sinl,
etc).  The libstdc++ configury seems to activate the related std methods
only if *all* related C library functions for double, float and long
double (e.g. cos, cosf, cosl) are implemented by the platform.

Yes. The attached patch for cmath include file would fix this.

Christian

--- /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/cmath.orig	2015-02-24 02:02:20.000000000 +0100
+++ /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/cmath	2015-03-13 09:39:58.098696700 +0100
@@ -922,7 +922,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
 
 #if __cplusplus >= 201103L
 
-#ifdef _GLIBCXX_USE_C99_MATH_TR1
+#if defined(_GLIBCXX_USE_C99_MATH_TR1) || defined(__CYGWIN__)
 
 #undef acosh
 #undef acoshf
@@ -1041,87 +1041,66 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // functions
   using ::acosh;
   using ::acoshf;
-  using ::acoshl;
 
   using ::asinh;
   using ::asinhf;
-  using ::asinhl;
 
   using ::atanh;
   using ::atanhf;
-  using ::atanhl;
 
   using ::cbrt;
   using ::cbrtf;
-  using ::cbrtl;
 
   using ::copysign;
   using ::copysignf;
-  using ::copysignl;
 
   using ::erf;
   using ::erff;
-  using ::erfl;
 
   using ::erfc;
   using ::erfcf;
-  using ::erfcl;
 
   using ::exp2;
   using ::exp2f;
-  using ::exp2l;
 
   using ::expm1;
   using ::expm1f;
-  using ::expm1l;
 
   using ::fdim;
   using ::fdimf;
-  using ::fdiml;
 
   using ::fma;
   using ::fmaf;
-  using ::fmal;
 
   using ::fmax;
   using ::fmaxf;
-  using ::fmaxl;
 
   using ::fmin;
   using ::fminf;
-  using ::fminl;
 
   using ::hypot;
   using ::hypotf;
-  using ::hypotl;
 
   using ::ilogb;
   using ::ilogbf;
-  using ::ilogbl;
 
   using ::lgamma;
   using ::lgammaf;
-  using ::lgammal;
 
   using ::llrint;
   using ::llrintf;
-  using ::llrintl;
 
   using ::llround;
   using ::llroundf;
-  using ::llroundl;
 
   using ::log1p;
   using ::log1pf;
-  using ::log1pl;
 
   using ::log2;
   using ::log2f;
-  using ::log2l;
 
   using ::logb;
   using ::logbf;
-  using ::logbl;
 
   using ::lrint;
   using ::lrintf;
@@ -1129,31 +1108,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   using ::lround;
   using ::lroundf;
-  using ::lroundl;
 
   using ::nan;
   using ::nanf;
-  using ::nanl;
 
   using ::nearbyint;
   using ::nearbyintf;
-  using ::nearbyintl;
 
   using ::nextafter;
   using ::nextafterf;
-  using ::nextafterl;
-
-  using ::nexttoward;
-  using ::nexttowardf;
-  using ::nexttowardl;
 
   using ::remainder;
   using ::remainderf;
-  using ::remainderl;
 
   using ::remquo;
   using ::remquof;
-  using ::remquol;
 
   using ::rint;
   using ::rintf;
@@ -1161,23 +1130,56 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   using ::round;
   using ::roundf;
-  using ::roundl;
 
   using ::scalbln;
   using ::scalblnf;
-  using ::scalblnl;
 
   using ::scalbn;
   using ::scalbnf;
-  using ::scalbnl;
 
   using ::tgamma;
   using ::tgammaf;
-  using ::tgammal;
 
   using ::trunc;
   using ::truncf;
+
+#ifndef __CYGWIN__
+  using ::acoshl;
+  using ::asinhl;
+  using ::atanhl;
+  using ::cbrtl;
+  using ::copysignl;
+  using ::erfl;
+  using ::erfcl;
+  using ::exp2l;
+  using ::expm1l;
+  using ::fdiml;
+  using ::fmal;
+  using ::fmaxl;
+  using ::fminl;
+  using ::hypotl;
+  using ::ilogbl;
+  using ::lgammal;
+  using ::llrintl;
+  using ::llroundl;
+  using ::log1pl;
+  using ::log2l;
+  using ::logbl;
+  using ::lroundl;
+  using ::nanl;
+  using ::nearbyintl;
+  using ::nextafterl;
+  using ::nexttoward;
+  using ::nexttowardf;
+  using ::nexttowardl;
+  using ::remainderl;
+  using ::remquol;
+  using ::roundl;
+  using ::scalblnl;
+  using ::scalbnl;
+  using ::tgammal;
   using ::truncl;
+#endif
 
   /// Additional overloads.
   constexpr float

--
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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]