public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/61985] New: It's possible to declare a function pointer as noreturn using the old volatile syntax but not normally.
@ 2014-07-31 22:42 sstewartgallus00 at mylangara dot bc.ca
2014-07-31 23:22 ` [Bug c/61985] " joseph at codesourcery dot com
2014-08-01 4:47 ` mpolacek at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: sstewartgallus00 at mylangara dot bc.ca @ 2014-07-31 22:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61985
Bug ID: 61985
Summary: It's possible to declare a function pointer as
noreturn using the old volatile syntax but not
normally.
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: sstewartgallus00 at mylangara dot bc.ca
It's against the C11 standard to let people use the _Noreturn keyword on a
function pointer type. It's treated the same as the inline keyword. In my
opinion this is silly but whatever. Anyways, it is possible to declare a
function pointer as noreturn using the old volatile syntax but not using the
noreturn keyword or attribute. Eg)
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdnoreturn.h>
typedef void f(void * restrict, int);
typedef volatile f next_t;
__attribute__((noinline)) noreturn void increment(void * restrict context,
next_t * next,
int xx)
{
next(context, xx + 1);
}
__attribute__((noinline)) noreturn void main_1(void * restrict context, int
xx);
__attribute__((noinline)) noreturn void main_2(void * restrict context, int
xx);
int main(void)
{
{
int value = 4;
printf("value: %i\n", value);
increment(NULL, main_1, value);
}
}
__attribute__((noinline)) noreturn void main_1(void * restrict context, int xx)
{
printf("value + 1: %i\n", xx);
increment(NULL, main_2, xx);
}
__attribute__((noinline)) noreturn void main_2(void * restrict context, int xx)
{
printf("value + 2: %i\n", xx);
exit(EXIT_FAILURE);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/61985] It's possible to declare a function pointer as noreturn using the old volatile syntax but not normally.
2014-07-31 22:42 [Bug c/61985] New: It's possible to declare a function pointer as noreturn using the old volatile syntax but not normally sstewartgallus00 at mylangara dot bc.ca
@ 2014-07-31 23:22 ` joseph at codesourcery dot com
2014-08-01 4:47 ` mpolacek at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: joseph at codesourcery dot com @ 2014-07-31 23:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61985
--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
I'm afraid I can't tell what you think the bug here is. You make a true
statement about C11 - that's not a bug report. You give some C code -
that's not a bug report either. You don't say what GCC version or
command-line options you use with the C code, or what you think GCC is
doing wrong with that code, why you think that is wrong and what you think
it should do instead.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/61985] It's possible to declare a function pointer as noreturn using the old volatile syntax but not normally.
2014-07-31 22:42 [Bug c/61985] New: It's possible to declare a function pointer as noreturn using the old volatile syntax but not normally sstewartgallus00 at mylangara dot bc.ca
2014-07-31 23:22 ` [Bug c/61985] " joseph at codesourcery dot com
@ 2014-08-01 4:47 ` mpolacek at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-08-01 4:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61985
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |mpolacek at gcc dot gnu.org
Resolution|--- |INVALID
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The reporter seems to complain that it is not possible to declare a function
pointer as noreturn using the noreturn keyword or attribute. But the attribute
should work:
__attribute__ ((__noreturn__)) void (*fp1) (void); // OK
_Noreturn void (*fp2) (void); // invalid
You only have to be careful that if you include <stdnoreturn.h>, the "noreturn"
gets expanded to _Noreturn, so you'd get "attribute directive ignored".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-08-01 4:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-31 22:42 [Bug c/61985] New: It's possible to declare a function pointer as noreturn using the old volatile syntax but not normally sstewartgallus00 at mylangara dot bc.ca
2014-07-31 23:22 ` [Bug c/61985] " joseph at codesourcery dot com
2014-08-01 4:47 ` mpolacek at gcc dot gnu.org
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 read-only IMAP folder(s) and NNTP newsgroup(s).