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
[-- Attachment #1 --] On Fri, Feb 2, 2024, 11:28 AM 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=c27a89971805b176dcfa5a234f2ea6f6109d0a70 > > > > 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 >= 1999 */ > > > > /* > > @@ -163,9 +163,9 @@ _Noreturn void _Exit(int); > > #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 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 >= 2011 */ > > /* > > * Extensions made by POSIX relative to C. > [-- Attachment #2 --] <div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 2, 2024, 11:28 AM Konstantin Belousov <<a href="mailto:kostikbel@gmail.com">kostikbel@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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: <a href="https://cgit.FreeBSD.org/src/commit/?id=c27a89971805b176dcfa5a234f2ea6f6109d0a70" rel="noreferrer noreferrer" target="_blank">https://cgit.FreeBSD.org/src/commit/?id=c27a89971805b176dcfa5a234f2ea6f6109d0a70</a><br> > <br> > commit c27a89971805b176dcfa5a234f2ea6f6109d0a70<br> > Author: Lexi Winter <lexi@le-Fay.ORG><br> > AuthorDate: 2024-02-02 16:41:40 +0000<br> > Commit: Warner Losh <imp@FreeBSD.org><br> > CommitDate: 2024-02-02 18:11:17 +0000<br> > <br> > stdlib.h: add __noexcept to prototypes<br> > <br> > The noexcept specifier is required on these functions in C++:<br> > _Exit(), atexit(), quick_exit(), at_quick_exit(), abort().<br> > <br> > MFC after: 2 weeks<br> > <br> > Reviewed by: imp<br> > Pull Request: <a href="https://github.com/freebsd/freebsd-src/pull/1085" rel="noreferrer noreferrer" target="_blank">https://github.com/freebsd/freebsd-src/pull/1085</a><br> > ---<br> > include/stdlib.h | 10 +++++-----<br> > 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> > extern int ___mb_cur_max(void);<br> > #define MB_CUR_MAX ((size_t)___mb_cur_max())<br> > <br> > -_Noreturn void abort(void);<br> > +_Noreturn void abort(void) __noexcept;<br> > int abs(int) __pure2;<br> > -int atexit(void (* _Nonnull)(void));<br> > +int atexit(void (* _Nonnull)(void)) __noexcept;<br> > double atof(const char *);<br> > int atoi(const char *);<br> > long atol(const char *);<br> > @@ -154,7 +154,7 @@ unsigned long long<br> > strtoull(const char * __restrict, char ** __restrict, int);<br> > #endif /* __LONG_LONG_SUPPORTED */<br> > <br> > -_Noreturn void _Exit(int);<br> > +_Noreturn void _Exit(int) __noexcept;<br> > #endif /* __ISO_C_VISIBLE >= 1999 */<br> > <br> > /*<br> > @@ -163,9 +163,9 @@ _Noreturn void _Exit(int);<br> > #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L<br> > void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)<br> > __alloc_size(2);<br> > -int at_quick_exit(void (*)(void));<br> > +int at_quick_exit(void (*)(void)) __noexcept;<br> > _Noreturn void<br> > - quick_exit(int);<br> > + quick_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="auto"><br></div><div dir="auto">So is this just for quick_exit, or all the functions marked?</div><div dir="auto"><br></div><div dir="auto">Warner </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br> > #endif /* __ISO_C_VISIBLE >= 2011 */<br> > /*<br> > * Extensions made by POSIX relative to C.<br> </blockquote></div></div></div>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfq-uRbMmHuW8EHj5BzFrZwrju4Wh46kOQnrG-mvMDQS2Q>
