public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* Problem with libstdc++ documentation for math functions
@ 2021-03-24  0:32 Julio Pacheco
  2021-03-24  8:34 ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Julio Pacheco @ 2021-03-24  0:32 UTC (permalink / raw)
  To: libstdc++

I noticed that libstdc++ documentation didnt match the cmath lib while i
was trying to use the std::ceill function (std::ceil overload currently),
so i decided do make some changes in a patch file and posted it on ym
github! Since im fairly new with github im not sure how to take it from
here, ill link the file i made with the changes here, maybe you can either
tell me what else i can do to make things easier for you guys, or take
things from here yourself. Im a student that enjoys c++ alot.

(the link to the file where i made the changes, in github:)

https://github.com/thisusernameonlyhasthirtyninecharacters/libstdc-math-functions-update/blob/main/libstdc%2B%2B_patch.h

https://github.com/thisusernameonlyhasthirtyninecharacters/libstdc-math-functions-update

Sorry if this isnt the proper way to present issues, but it's my first time
doing this so i hope you can understand.

Regardless, thank you
-- 
Júlio Pacheco

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem with libstdc++ documentation for math functions
  2021-03-24  0:32 Problem with libstdc++ documentation for math functions Julio Pacheco
@ 2021-03-24  8:34 ` Jonathan Wakely
  2021-03-24 14:23   ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2021-03-24  8:34 UTC (permalink / raw)
  To: Julio Pacheco; +Cc: libstdc++

On Wed, 24 Mar 2021, 00:34 Julio Pacheco via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:

> I noticed that libstdc++ documentation didnt match the cmath lib while i
> was trying to use the std::ceill function (std::ceil overload currently),
> so i decided do make some changes in a patch file and posted it on ym
> github! Since im fairly new with github im not sure how to take it from
> here, ill link the file i made with the changes here, maybe you can either
> tell me what else i can do to make things easier for you guys, or take
> things from here yourself. Im a student that enjoys c++ alot.
>
> (the link to the file where i made the changes, in github:)
>
>
> https://github.com/thisusernameonlyhasthirtyninecharacters/libstdc-math-functions-update/blob/main/libstdc%2B%2B_patch.h
>
>
> https://github.com/thisusernameonlyhasthirtyninecharacters/libstdc-math-functions-update


I don't see patches here, just copies of files with no history or relation
to the GCC versions of those files.

I'll try to figure out what you've changed, but see
https://gcc.gnu.org/contribute.html for how to contribute patches that we
can use.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem with libstdc++ documentation for math functions
  2021-03-24  8:34 ` Jonathan Wakely
@ 2021-03-24 14:23   ` Jonathan Wakely
  2021-03-24 14:25     ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2021-03-24 14:23 UTC (permalink / raw)
  To: Julio Pacheco; +Cc: libstdc++

[-- Attachment #1: Type: text/plain, Size: 1949 bytes --]

On Wed, 24 Mar 2021 at 08:34, Jonathan Wakely wrote:
>
>
>
> On Wed, 24 Mar 2021, 00:34 Julio Pacheco via Libstdc++, <libstdc++@gcc.gnu.org> wrote:
>>
>> I noticed that libstdc++ documentation didnt match the cmath lib while i
>> was trying to use the std::ceill function (std::ceil overload currently),
>> so i decided do make some changes in a patch file and posted it on ym
>> github! Since im fairly new with github im not sure how to take it from
>> here, ill link the file i made with the changes here, maybe you can either
>> tell me what else i can do to make things easier for you guys, or take
>> things from here yourself. Im a student that enjoys c++ alot.
>>
>> (the link to the file where i made the changes, in github:)
>>
>> https://github.com/thisusernameonlyhasthirtyninecharacters/libstdc-math-functions-update/blob/main/libstdc%2B%2B_patch.h
>>
>> https://github.com/thisusernameonlyhasthirtyninecharacters/libstdc-math-functions-update
>
>
> I don't see patches here, just copies of files with no history or relation to the GCC versions of those files.
>
> I'll try to figure out what you've changed, but see https://gcc.gnu.org/contribute.html for how to contribute patches that we can use.

OK on closer inspection I see what you're trying to do with this
"patch". It's completely wrong though. In C++ the name std::ceil is
overloaded so you can call it with float arguments, and double
arguments, and long double arguments. Your changes completely break
that, so that only the ceil(double) overload would be declared.

The C++ library should *also* define std::ceill(long double) and
std::ceilf(float), and it's a bug that we don't have those:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79700
But you can't fix that bug by breaking all the existing overloads.

A partial fix is attached (as a diff against the current Git 'master'
branch), but it only fixes the overloads for C89 <math.h> functions,
not the C99 additions.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 5987 bytes --]

commit 3a8c7feb27daf1fee54fb4937b4985e2fa2fc330
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Mar 24 14:20:33 2021

    libstdc++: Add missing using-declarations to <cmath> [PR 79700]
    
    PARTIAL FIX
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/79700
            * include/c_global/cmath: TODO write me.

diff --git a/libstdc++-v3/include/c_global/cmath b/libstdc++-v3/include/c_global/cmath
index 39a6b036b8c..9d71439c833 100644
--- a/libstdc++-v3/include/c_global/cmath
+++ b/libstdc++-v3/include/c_global/cmath
@@ -51,28 +51,74 @@
 
 // Get rid of those macros defined in <math.h> in lieu of real functions.
 #undef div
+#undef divf
+#undef divl
 #undef acos
+#undef acosf
+#undef acosl
 #undef asin
+#undef asinf
+#undef asinl
 #undef atan
+#undef atanf
+#undef atanl
 #undef atan2
+#undef atan2f
+#undef atan2l
 #undef ceil
+#undef ceilf
+#undef ceill
 #undef cos
+#undef cosf
+#undef cosl
 #undef cosh
+#undef coshf
+#undef coshl
 #undef exp
+#undef expf
+#undef expl
 #undef fabs
+#undef fabsf
+#undef fabsl
 #undef floor
+#undef floorf
+#undef floorl
 #undef fmod
+#undef fmodf
+#undef fmodl
 #undef frexp
+#undef frexpf
+#undef frexpl
 #undef ldexp
+#undef ldexpf
+#undef ldexpl
 #undef log
+#undef logf
+#undef logl
 #undef log10
+#undef log10f
+#undef log10l
 #undef modf
+#undef modff
+#undef modfl
 #undef pow
+#undef powf
+#undef powl
 #undef sin
+#undef sinf
+#undef sinl
 #undef sinh
+#undef sinhf
+#undef sinhl
 #undef sqrt
+#undef sqrtf
+#undef sqrtl
 #undef tan
+#undef tanf
+#undef tanl
 #undef tanh
+#undef tanhf
+#undef tanhl
 
 extern "C++"
 {
@@ -99,6 +145,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     acos(_Tp __x)
     { return __builtin_acos(__x); }
 
+  using ::acosf;
+  using ::acosl;
+
   using ::asin;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -118,6 +167,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     asin(_Tp __x)
     { return __builtin_asin(__x); }
 
+  using ::asinf;
+  using ::asinl;
+
   using ::atan;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -137,6 +189,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     atan(_Tp __x)
     { return __builtin_atan(__x); }
 
+  using ::atanf;
+  using ::atanl;
+
   using ::atan2;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -158,6 +213,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return atan2(__type(__y), __type(__x));
     }
 
+  using ::atan2f;
+  using ::atan2l;
+
   using ::ceil;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -177,6 +235,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     ceil(_Tp __x)
     { return __builtin_ceil(__x); }
 
+  using ::ceilf;
+  using ::ceill;
+
   using ::cos;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -196,6 +257,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     cos(_Tp __x)
     { return __builtin_cos(__x); }
 
+  using ::cosf;
+  using ::cosl;
+
   using ::cosh;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -215,6 +279,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     cosh(_Tp __x)
     { return __builtin_cosh(__x); }
 
+  using ::coshf;
+  using ::coshl;
+
   using ::exp;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -234,6 +301,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     exp(_Tp __x)
     { return __builtin_exp(__x); }
 
+  using ::expf;
+  using ::expl;
+
   using ::fabs;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -253,6 +323,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     fabs(_Tp __x)
     { return __builtin_fabs(__x); }
 
+  using ::fabsf;
+  using ::fabsl;
+
   using ::floor;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -272,6 +345,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     floor(_Tp __x)
     { return __builtin_floor(__x); }
 
+  using ::floorf;
+  using ::floorl;
+
   using ::fmod;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -293,6 +369,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return fmod(__type(__x), __type(__y));
     }
 
+  using ::fmodf;
+  using ::fmodl;
+
   using ::frexp;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -312,6 +391,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     frexp(_Tp __x, int* __exp)
     { return __builtin_frexp(__x, __exp); }
 
+  using ::frexpf;
+  using ::frexpl;
+
   using ::ldexp;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -331,6 +413,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     ldexp(_Tp __x, int __exp)
     { return __builtin_ldexp(__x, __exp); }
 
+  using ::ldexpf;
+  using ::ldexpl;
+
   using ::log;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -350,6 +435,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     log(_Tp __x)
     { return __builtin_log(__x); }
 
+  using ::logf;
+  using ::logl;
+
   using ::log10;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -369,6 +457,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     log10(_Tp __x)
     { return __builtin_log10(__x); }
 
+  using ::log10f;
+  using ::log10l;
+
   using ::modf;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -381,6 +472,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   { return __builtin_modfl(__x, __iptr); }
 #endif
 
+  using ::modff;
+  using ::modfl;
+
   using ::pow;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -418,6 +512,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return pow(__type(__x), __type(__y));
     }
 
+  using ::powf;
+  using ::powl;
+
   using ::sin;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -437,6 +534,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     sin(_Tp __x)
     { return __builtin_sin(__x); }
 
+  using ::sinf;
+  using ::sinl;
+
   using ::sinh;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -456,6 +556,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     sinh(_Tp __x)
     { return __builtin_sinh(__x); }
 
+  using ::sinhf;
+  using ::sinhl;
+
   using ::sqrt;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -475,6 +578,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     sqrt(_Tp __x)
     { return __builtin_sqrt(__x); }
 
+  using ::sqrtf;
+  using ::sqrtl;
+
   using ::tan;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
@@ -494,6 +600,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     tan(_Tp __x)
     { return __builtin_tan(__x); }
 
+  using ::tanf;
+  using ::tanl;
+
   using ::tanh;
 
 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem with libstdc++ documentation for math functions
  2021-03-24 14:23   ` Jonathan Wakely
@ 2021-03-24 14:25     ` Jonathan Wakely
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2021-03-24 14:25 UTC (permalink / raw)
  To: Julio Pacheco; +Cc: libstdc++

On Wed, 24 Mar 2021 at 14:23, Jonathan Wakely wrote:
>
> On Wed, 24 Mar 2021 at 08:34, Jonathan Wakely wrote:
> >
> >
> >
> > On Wed, 24 Mar 2021, 00:34 Julio Pacheco via Libstdc++, <libstdc++@gcc.gnu.org> wrote:
> >>
> >> I noticed that libstdc++ documentation didnt match the cmath lib while i
> >> was trying to use the std::ceill function (std::ceil overload currently),

P.S. I meant to ask, what documentation do you think doesn't match <cmath>?

As a workaround, your code can just use std::ceil, which works with
long double arguments.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-24 14:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24  0:32 Problem with libstdc++ documentation for math functions Julio Pacheco
2021-03-24  8:34 ` Jonathan Wakely
2021-03-24 14:23   ` Jonathan Wakely
2021-03-24 14:25     ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).