Date: Fri, 2 Feb 2024 11:36:35 -0700 From: Warner Losh <imp@bsdimp.com> To: Konstantin Belousov <kostikbel@gmail.com> Cc: Warner Losh <imp@freebsd.org>, src-committers <src-committers@freebsd.org>, "<dev-commits-src-all@freebsd.org>" <dev-commits-src-all@freebsd.org>, "<dev-commits-src-main@freebsd.org>" <dev-commits-src-main@freebsd.org> Subject: Re: git: c27a89971805 - main - stdlib.h: add __noexcept to prototypes Message-ID: <CANCZdfq-uRbMmHuW8EHj5BzFrZwrju4Wh46kOQnrG-mvMDQS2Q@mail.gmail.com> In-Reply-To: <Zb00WYdB01tU9sWq@kib.kiev.ua> References: <202402021816.412IGxAl070009@gitrepo.freebsd.org> <Zb00WYdB01tU9sWq@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
--0000000000000149be06106a659a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Feb 2, 2024, 11:28=E2=80=AFAM Konstantin Belousov <kostikbel@gmail.= com> wrote: > On Fri, Feb 02, 2024 at 06:16:59PM +0000, Warner Losh wrote: > > The branch main has been updated by imp: > > > > URL: > https://cgit.FreeBSD.org/src/commit/?id=3Dc27a89971805b176dcfa5a234f2ea6f= 6109d0a70 > > > > commit c27a89971805b176dcfa5a234f2ea6f6109d0a70 > > Author: Lexi Winter <lexi@le-Fay.ORG> > > AuthorDate: 2024-02-02 16:41:40 +0000 > > Commit: Warner Losh <imp@FreeBSD.org> > > CommitDate: 2024-02-02 18:11:17 +0000 > > > > stdlib.h: add __noexcept to prototypes > > > > The noexcept specifier is required on these functions in C++: > > _Exit(), atexit(), quick_exit(), at_quick_exit(), abort(). > > > > MFC after: 2 weeks > > > > Reviewed by: imp > > Pull Request: https://github.com/freebsd/freebsd-src/pull/1085 > > --- > > include/stdlib.h | 10 +++++----- > > 1 file changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/include/stdlib.h b/include/stdlib.h > > index ff8991d1fa94..f0687f01e6c7 100644 > > --- a/include/stdlib.h > > +++ b/include/stdlib.h > > @@ -84,9 +84,9 @@ extern int __mb_cur_max; > > extern int ___mb_cur_max(void); > > #define MB_CUR_MAX ((size_t)___mb_cur_max()) > > > > -_Noreturn void abort(void); > > +_Noreturn void abort(void) __noexcept; > > int abs(int) __pure2; > > -int atexit(void (* _Nonnull)(void)); > > +int atexit(void (* _Nonnull)(void)) __noexcept; > > double atof(const char *); > > int atoi(const char *); > > long atol(const char *); > > @@ -154,7 +154,7 @@ unsigned long long > > strtoull(const char * __restrict, char ** __restrict, int); > > #endif /* __LONG_LONG_SUPPORTED */ > > > > -_Noreturn void _Exit(int); > > +_Noreturn void _Exit(int) __noexcept; > > #endif /* __ISO_C_VISIBLE >=3D 1999 */ > > > > /* > > @@ -163,9 +163,9 @@ _Noreturn void _Exit(int); > > #if __ISO_C_VISIBLE >=3D 2011 || __cplusplus >=3D 201103L > > void * aligned_alloc(size_t, size_t) __malloc_like > __alloc_align(1) > > __alloc_size(2); > > -int at_quick_exit(void (*)(void)); > > +int at_quick_exit(void (*)(void)) __noexcept; > > _Noreturn void > > - quick_exit(int); > > + quick_exit(int) __noexcept; > This is wrong, libc quick_exit() does not provide such guarantees as > implemented. More, being part of libc it cannot ever guarantee that ever > (and call std::terminate if the requirement is violated). > > Making it such would require bringing some C++ ABI into libc which I > object strongly. > So is this just for quick_exit, or all the functions marked? Warner > > #endif /* __ISO_C_VISIBLE >=3D 2011 */ > > /* > > * Extensions made by POSIX relative to C. > --0000000000000149be06106a659a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto"><div><br><br><div class=3D"gmail_quote"><div dir=3D"ltr" = class=3D"gmail_attr">On Fri, Feb 2, 2024, 11:28=E2=80=AFAM Konstantin Belou= sov <<a href=3D"mailto:kostikbel@gmail.com">kostikbel@gmail.com</a>> = wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8e= x;border-left:1px #ccc solid;padding-left:1ex">On Fri, Feb 02, 2024 at 06:1= 6:59PM +0000, Warner Losh wrote:<br> > The branch main has been updated by imp:<br> > <br> > URL: <a href=3D"https://cgit.FreeBSD.org/src/commit/?id=3Dc27a89971805= b176dcfa5a234f2ea6f6109d0a70" rel=3D"noreferrer noreferrer" target=3D"_blan= k">https://cgit.FreeBSD.org/src/commit/?id=3Dc27a89971805b176dcfa5a234f2ea6= f6109d0a70</a><br> > <br> > commit c27a89971805b176dcfa5a234f2ea6f6109d0a70<br> > Author:=C2=A0 =C2=A0 =C2=A0Lexi Winter <lexi@le-Fay.ORG><br> > AuthorDate: 2024-02-02 16:41:40 +0000<br> > Commit:=C2=A0 =C2=A0 =C2=A0Warner Losh <imp@FreeBSD.org><br> > CommitDate: 2024-02-02 18:11:17 +0000<br> > <br> >=C2=A0 =C2=A0 =C2=A0stdlib.h: add __noexcept to prototypes<br> >=C2=A0 =C2=A0 =C2=A0<br> >=C2=A0 =C2=A0 =C2=A0The noexcept specifier is required on these functio= ns in C++:<br> >=C2=A0 =C2=A0 =C2=A0_Exit(), atexit(), quick_exit(), at_quick_exit(), a= bort().<br> >=C2=A0 =C2=A0 =C2=A0<br> >=C2=A0 =C2=A0 =C2=A0MFC after:=C2=A0 =C2=A0 =C2=A0 2 weeks<br> >=C2=A0 =C2=A0 =C2=A0<br> >=C2=A0 =C2=A0 =C2=A0Reviewed by: imp<br> >=C2=A0 =C2=A0 =C2=A0Pull Request: <a href=3D"https://github.com/freebsd= /freebsd-src/pull/1085" rel=3D"noreferrer noreferrer" target=3D"_blank">htt= ps://github.com/freebsd/freebsd-src/pull/1085</a><br> > ---<br> >=C2=A0 include/stdlib.h | 10 +++++-----<br> >=C2=A0 1 file changed, 5 insertions(+), 5 deletions(-)<br> > <br> > diff --git a/include/stdlib.h b/include/stdlib.h<br> > index ff8991d1fa94..f0687f01e6c7 100644<br> > --- a/include/stdlib.h<br> > +++ b/include/stdlib.h<br> > @@ -84,9 +84,9 @@ extern int __mb_cur_max;<br> >=C2=A0 extern int ___mb_cur_max(void);<br> >=C2=A0 #define=C2=A0 =C2=A0 =C2=A0 MB_CUR_MAX=C2=A0 =C2=A0 =C2=A0 ((siz= e_t)___mb_cur_max())<br> >=C2=A0 <br> > -_Noreturn void=C2=A0 =C2=A0 =C2=A0 =C2=A0 abort(void);<br> > +_Noreturn void=C2=A0 =C2=A0 =C2=A0 =C2=A0 abort(void) __noexcept;<br> >=C2=A0 int=C2=A0 =C2=A0abs(int) __pure2;<br> > -int=C2=A0 =C2=A0atexit(void (* _Nonnull)(void));<br> > +int=C2=A0 =C2=A0atexit(void (* _Nonnull)(void)) __noexcept;<br> >=C2=A0 double=C2=A0 =C2=A0 =C2=A0 =C2=A0 atof(const char *);<br> >=C2=A0 int=C2=A0 =C2=A0atoi(const char *);<br> >=C2=A0 long=C2=A0 atol(const char *);<br> > @@ -154,7 +154,7 @@ unsigned long long<br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 strtoull(const char * __restrict, char ** _= _restrict, int);<br> >=C2=A0 #endif /* __LONG_LONG_SUPPORTED */<br> >=C2=A0 <br> > -_Noreturn void=C2=A0 =C2=A0 =C2=A0 =C2=A0 _Exit(int);<br> > +_Noreturn void=C2=A0 =C2=A0 =C2=A0 =C2=A0 _Exit(int) __noexcept;<br> >=C2=A0 #endif /* __ISO_C_VISIBLE >=3D 1999 */<br> >=C2=A0 <br> >=C2=A0 /*<br> > @@ -163,9 +163,9 @@ _Noreturn void=C2=A0 =C2=A0 =C2=A0_Exit(int);<br> >=C2=A0 #if __ISO_C_VISIBLE >=3D 2011 || __cplusplus >=3D 201103L<= br> >=C2=A0 void *=C2=A0 =C2=A0 =C2=A0 =C2=A0aligned_alloc(size_t, size_t) _= _malloc_like __alloc_align(1)<br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0__alloc_size(2);<br> > -int=C2=A0 at_quick_exit(void (*)(void));<br> > +int=C2=A0 at_quick_exit(void (*)(void)) __noexcept;<br> >=C2=A0 _Noreturn void<br> > -=C2=A0 =C2=A0 =C2=A0quick_exit(int);<br> > +=C2=A0 =C2=A0 =C2=A0quick_exit(int) __noexcept;<br> This is wrong, libc quick_exit() does not provide such guarantees as<br> implemented. More, being part of libc it cannot ever guarantee that ever<br= > (and call std::terminate if the requirement is violated).<br> <br> Making it such would require bringing some C++ ABI into libc which I<br> object strongly.<br></blockquote></div></div><div dir=3D"auto"><br></div><d= iv dir=3D"auto">So is this just for quick_exit, or all the functions marked= ?</div><div dir=3D"auto"><br></div><div dir=3D"auto">Warner=C2=A0</div><div= dir=3D"auto"><br></div><div dir=3D"auto"><div class=3D"gmail_quote"><block= quote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc= solid;padding-left:1ex"> <br> >=C2=A0 #endif /* __ISO_C_VISIBLE >=3D 2011 */<br> >=C2=A0 /*<br> >=C2=A0 =C2=A0* Extensions made by POSIX relative to C.<br> </blockquote></div></div></div> --0000000000000149be06106a659a--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfq-uRbMmHuW8EHj5BzFrZwrju4Wh46kOQnrG-mvMDQS2Q>