Date: Fri, 2 Feb 2024 12:02:39 -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: <CANCZdfoTV_Zn4NfvB%2BaPhB_uAj5qjuOersD8WJkZNskqz5A_sQ@mail.gmail.com> In-Reply-To: <Zb07fS0uA8C_0AaL@kib.kiev.ua> References: <202402021816.412IGxAl070009@gitrepo.freebsd.org> <Zb00WYdB01tU9sWq@kib.kiev.ua> <CANCZdfq-uRbMmHuW8EHj5BzFrZwrju4Wh46kOQnrG-mvMDQS2Q@mail.gmail.com> <Zb07fS0uA8C_0AaL@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
--0000000000002ca5bf06106ac272 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Feb 2, 2024 at 11:59=E2=80=AFAM Konstantin Belousov <kostikbel@gmai= l.com> wrote: > On Fri, Feb 02, 2024 at 11:36:35AM -0700, Warner Losh wrote: > > On Fri, Feb 2, 2024, 11:28=E2=80=AFAM Konstantin Belousov <kostikbel@gm= ail.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? > Other functions are abort()/_Exit()/atexit(). No functions in this list > call a user-provided functions, so they cannot raise exceptions. > > My objection is only against our quick_exit(). > OK. I'll back that one out. Warner --0000000000002ca5bf06106ac272 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">= <div dir=3D"ltr" class=3D"gmail_attr">On Fri, Feb 2, 2024 at 11:59=E2=80=AF= AM Konstantin Belousov <<a href=3D"mailto:kostikbel@gmail.com">kostikbel= @gmail.com</a>> wrote:<br></div><blockquote class=3D"gmail_quote" style= =3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding= -left:1ex">On Fri, Feb 02, 2024 at 11:36:35AM -0700, Warner Losh wrote:<br> > On Fri, Feb 2, 2024, 11:28=E2=80=AFAM Konstantin Belousov <<a href= =3D"mailto:kostikbel@gmail.com" target=3D"_blank">kostikbel@gmail.com</a>&g= t;<br> > wrote:<br> > <br> > > On Fri, Feb 02, 2024 at 06:16:59PM +0000, Warner Losh wrote:<br> > > > The branch main has been updated by imp:<br> > > ><br> > > > URL:<br> > > <a href=3D"https://cgit.FreeBSD.org/src/commit/?id=3Dc27a89971805= b176dcfa5a234f2ea6f6109d0a70" rel=3D"noreferrer" target=3D"_blank">https://= cgit.FreeBSD.org/src/commit/?id=3Dc27a89971805b176dcfa5a234f2ea6f6109d0a70<= /a><br> > > ><br> > > > commit c27a89971805b176dcfa5a234f2ea6f6109d0a70<br> > > > Author:=C2=A0 =C2=A0 =C2=A0Lexi Winter <lexi@le-Fay.ORG&g= t;<br> > > > AuthorDate: 2024-02-02 16:41:40 +0000<br> > > > Commit:=C2=A0 =C2=A0 =C2=A0Warner Losh <imp@FreeBSD.org&g= t;<br> > > > CommitDate: 2024-02-02 18:11:17 +0000<br> > > ><br> > > >=C2=A0 =C2=A0 =C2=A0stdlib.h: add __noexcept to prototypes<br= > > > ><br> > > >=C2=A0 =C2=A0 =C2=A0The noexcept specifier is required on the= se functions in C++:<br> > > >=C2=A0 =C2=A0 =C2=A0_Exit(), atexit(), quick_exit(), at_quick= _exit(), abort().<br> > > ><br> > > >=C2=A0 =C2=A0 =C2=A0MFC after:=C2=A0 =C2=A0 =C2=A0 2 weeks<br= > > > ><br> > > >=C2=A0 =C2=A0 =C2=A0Reviewed by: imp<br> > > >=C2=A0 =C2=A0 =C2=A0Pull Request: <a href=3D"https://github.c= om/freebsd/freebsd-src/pull/1085" rel=3D"noreferrer" target=3D"_blank">http= s://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 ((size_t)___mb_cur_max())<br> > > ><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) __noe= xcept;<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> > > ><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) __noex= cept;<br> > > >=C2=A0 #endif /* __ISO_C_VISIBLE >=3D 1999 */<br> > > ><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<br> > > __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 th= at ever<br> > > (and call std::terminate if the requirement is violated).<br> > ><br> > > Making it such would require bringing some C++ ABI into libc whic= h I<br> > > object strongly.<br> > ><br> > <br> > So is this just for quick_exit, or all the functions marked?<br> Other functions are abort()/_Exit()/atexit(). No functions in this list<br> call a user-provided functions, so they cannot raise exceptions.<br> <br> My objection is only against our quick_exit().<br></blockquote><div><br></d= iv><div>OK. I'll back that one out.</div><div><br></div><div>Warner=C2= =A0</div></div></div> --0000000000002ca5bf06106ac272--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfoTV_Zn4NfvB%2BaPhB_uAj5qjuOersD8WJkZNskqz5A_sQ>