From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14230 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] Use __attribute__((noreturn)) for function pointer Date: Fri, 14 Jun 2019 12:47:38 -0400 Message-ID: <20190614164738.GI1506@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="28110"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-14246-gllmg-musl=m.gmane.org@lists.openwall.com Fri Jun 14 18:48:01 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hbpMt-000792-Ty for gllmg-musl@m.gmane.org; Fri, 14 Jun 2019 18:48:00 +0200 Original-Received: (qmail 15865 invoked by uid 550); 14 Jun 2019 16:47:51 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 15812 invoked from network); 14 Jun 2019 16:47:50 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14230 Archived-At: On Fri, Jun 14, 2019 at 09:42:09AM -0700, Matthew Maurer wrote: > _Noreturn doesn't actually exist in C99 - that's a C11ism. Even in C11, it > cannot be used on a function pointer type. > __attribute__((noreturn)) is a GNU C extension (which we're allowed to use, > unlike C11), and is allowed to be placed on function pointer types. > From adeca3acc1e4c1b727e8524542c201b436ba8a5b Mon Sep 17 00:00:00 2001 > From: Matthew Maurer > Date: Thu, 13 Jun 2019 12:33:38 -0700 > Subject: [PATCH] Use __attribute__((noreturn)) for function pointer > > _Noreturn is a C11 construct, and may only be used at the site of a > function definition. > __attribute__((noreturn)) is a GNU C extension which may be used on > function pointers. > GCC with any standard permits _Noreturn in the position it's used > (likely because it implements it in terms of attribute noreturn), but > Clang will reject it for any standard past C11, and warn pre-C11. > > Musl is written in C99 with GNU C extensions, so > __attribute__((noreturn)) is both more correct in that sense and allows > us to compile with Clang set to higher language standards. > --- > src/internal/dynlink.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/internal/dynlink.h b/src/internal/dynlink.h > index cbe0a6fe..d2bf6b41 100644 > --- a/src/internal/dynlink.h > +++ b/src/internal/dynlink.h > @@ -95,7 +95,7 @@ struct fdpic_dummy_loadmap { > #define DYN_CNT 32 > > typedef void (*stage2_func)(unsigned char *, size_t *); > -typedef _Noreturn void (*stage3_func)(size_t *); > +typedef __attribute__((noreturn)) void (*stage3_func)(size_t *); > > hidden void *__dlsym(void *restrict, const char *restrict, void *restrict); > > -- > 2.22.0.410.gd8fdbe21b5-goog > Just remove it. There's no sense having nonstandard C here for something that's completely inconsequential. It wasn't important, and probably the only reason I wrote it was wrongly thinking the function pointer type had to match the _Noreturn of the function definition. Rich