* [PATCH] Use __attribute__((noreturn)) for function pointer
@ 2019-06-14 16:42 Matthew Maurer
2019-06-14 16:47 ` Rich Felker
0 siblings, 1 reply; 4+ messages in thread
From: Matthew Maurer @ 2019-06-14 16:42 UTC (permalink / raw)
To: musl
[-- Attachment #1.1: Type: text/plain, Size: 262 bytes --]
_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.
[-- Attachment #1.2: Type: text/html, Size: 306 bytes --]
[-- Attachment #2: 0001-Use-__attribute__-noreturn-for-function-pointer.patch --]
[-- Type: text/x-patch, Size: 1369 bytes --]
From adeca3acc1e4c1b727e8524542c201b436ba8a5b Mon Sep 17 00:00:00 2001
From: Matthew Maurer <mmaurer@google.com>
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Use __attribute__((noreturn)) for function pointer
2019-06-14 16:42 [PATCH] Use __attribute__((noreturn)) for function pointer Matthew Maurer
@ 2019-06-14 16:47 ` Rich Felker
2019-06-14 16:50 ` Matthew Maurer
0 siblings, 1 reply; 4+ messages in thread
From: Rich Felker @ 2019-06-14 16:47 UTC (permalink / raw)
To: musl
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 <mmaurer@google.com>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Use __attribute__((noreturn)) for function pointer
2019-06-14 16:47 ` Rich Felker
@ 2019-06-14 16:50 ` Matthew Maurer
2019-06-25 22:58 ` Rich Felker
0 siblings, 1 reply; 4+ messages in thread
From: Matthew Maurer @ 2019-06-14 16:50 UTC (permalink / raw)
To: musl
[-- Attachment #1.1: Type: text/plain, Size: 2223 bytes --]
Done.
On Fri, Jun 14, 2019 at 9:47 AM Rich Felker <dalias@libc.org> wrote:
> 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 <mmaurer@google.com>
> > 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
>
[-- Attachment #1.2: Type: text/html, Size: 2869 bytes --]
[-- Attachment #2: 0001-Do-not-use-_Noreturn-for-a-function-pointer.patch --]
[-- Type: text/x-patch, Size: 866 bytes --]
From f31e064e7b2175e5a20552b6b2a627f5411d9b9f Mon Sep 17 00:00:00 2001
From: Matthew Maurer <mmaurer@google.com>
Date: Thu, 13 Jun 2019 12:33:38 -0700
Subject: [PATCH] Do not use _Noreturn for a function pointer
_Noreturn is a C11 construct, and may only be used at the site of a
function definition.
---
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..165bbedb 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 void (*stage3_func)(size_t *);
hidden void *__dlsym(void *restrict, const char *restrict, void *restrict);
--
2.22.0.410.gd8fdbe21b5-goog
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Use __attribute__((noreturn)) for function pointer
2019-06-14 16:50 ` Matthew Maurer
@ 2019-06-25 22:58 ` Rich Felker
0 siblings, 0 replies; 4+ messages in thread
From: Rich Felker @ 2019-06-25 22:58 UTC (permalink / raw)
To: musl
On Fri, Jun 14, 2019 at 09:50:45AM -0700, Matthew Maurer wrote:
> Done.
>
> On Fri, Jun 14, 2019 at 9:47 AM Rich Felker <dalias@libc.org> wrote:
>
> > 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 <mmaurer@google.com>
> > > 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.
> From f31e064e7b2175e5a20552b6b2a627f5411d9b9f Mon Sep 17 00:00:00 2001
> From: Matthew Maurer <mmaurer@google.com>
> Date: Thu, 13 Jun 2019 12:33:38 -0700
> Subject: [PATCH] Do not use _Noreturn for a function pointer
>
> _Noreturn is a C11 construct, and may only be used at the site of a
> function definition.
> ---
> 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..165bbedb 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 void (*stage3_func)(size_t *);
>
> hidden void *__dlsym(void *restrict, const char *restrict, void *restrict);
>
> --
> 2.22.0.410.gd8fdbe21b5-goog
>
I've had this in my local tree for a while, but hadn't built it
(didn't think I had to), and noticed that removing the _Noreturn from
the type but not from __dls2b and __dls3 caused warnings (errors with
my local -Werror) for "_Noreturn function returns". So I'm amending
this to also remove the _Noreturn from the definitions of these
functions, since it serves no purpose anyway. Now I think the only
remaining uses of _Noreturn are on public interfaces that are really
supposed to be _Noreturn.
Rich
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-25 22:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14 16:42 [PATCH] Use __attribute__((noreturn)) for function pointer Matthew Maurer
2019-06-14 16:47 ` Rich Felker
2019-06-14 16:50 ` Matthew Maurer
2019-06-25 22:58 ` Rich Felker
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).