public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/108194] New: GCC won't treat two compatible function types as compatible if any of them (or both of them) is declared _Noreturn
@ 2022-12-21 11:03 pskocik at gmail dot com
2022-12-21 13:03 ` [Bug c/108194] " rguenth at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: pskocik at gmail dot com @ 2022-12-21 11:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108194
Bug ID: 108194
Summary: GCC won't treat two compatible function types as
compatible if any of them (or both of them) is
declared _Noreturn
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: pskocik at gmail dot com
Target Milestone: ---
(same with __attribute((noreturn))) Example (https://godbolt.org/z/ePGd95sWz):
void FN_A(void);
void FN_B(void);
_Noreturn void NR_FN_A(void);
_Noreturn void NR_FN_B(void);
_Static_assert(_Generic((__typeof(*(FN_A))*){0}, __typeof(*(FN_B))*: 1), "");
//OK ✓
_Static_assert(_Generic((__typeof(*(NR_FN_A))*){0}, __typeof(*(NR_FN_B))*: 1),
""); //ERROR ✗
_Static_assert(_Generic((__typeof(*(FN_A))*){0}, __typeof(*(NR_FN_B))*: 1),
""); //ERROR ✗
As you can see from the Compiler Explorer link, clang accepts all three, which
is as it should be as per the standard, where _Noreturn is a function specifier
(https://port70.net/~nsz/c/c11/n1570.html#6.7.4), which means it shouldn't even
go into the type.
(Personally, I don't even mind it going into the type just as long as two
otherwise identical _Noreturn functio declarations are deemed as having the
same type).
Regards,
Petr Skocik
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/108194] GCC won't treat two compatible function types as compatible if any of them (or both of them) is declared _Noreturn
2022-12-21 11:03 [Bug c/108194] New: GCC won't treat two compatible function types as compatible if any of them (or both of them) is declared _Noreturn pskocik at gmail dot com
@ 2022-12-21 13:03 ` rguenth at gcc dot gnu.org
2022-12-21 13:25 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-12-21 13:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108194
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jsm28 at gcc dot gnu.org
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCCs own __attribute__((noreturn)) goes into the type to make indirect calls
annotatable.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/108194] GCC won't treat two compatible function types as compatible if any of them (or both of them) is declared _Noreturn
2022-12-21 11:03 [Bug c/108194] New: GCC won't treat two compatible function types as compatible if any of them (or both of them) is declared _Noreturn pskocik at gmail dot com
2022-12-21 13:03 ` [Bug c/108194] " rguenth at gcc dot gnu.org
@ 2022-12-21 13:25 ` pinskia at gcc dot gnu.org
2022-12-21 17:27 ` joseph at codesourcery dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-21 13:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108194
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note you are also using a gcc extension of __typeof so that could add it to the
type.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/108194] GCC won't treat two compatible function types as compatible if any of them (or both of them) is declared _Noreturn
2022-12-21 11:03 [Bug c/108194] New: GCC won't treat two compatible function types as compatible if any of them (or both of them) is declared _Noreturn pskocik at gmail dot com
2022-12-21 13:03 ` [Bug c/108194] " rguenth at gcc dot gnu.org
2022-12-21 13:25 ` pinskia at gcc dot gnu.org
@ 2022-12-21 17:27 ` joseph at codesourcery dot com
2022-12-21 17:36 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: joseph at codesourcery dot com @ 2022-12-21 17:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108194
--- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
If you use typeof instead of __typeof, and -std=c2x, these types are
treated as compatible. I deliberately kept the existing semantics for
__typeof, and for typeof in pre-C2x modes, when implementing C2x typeof;
see the commit message for commit fa258f6894801aef6785f0327594dc803da63fbd.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/108194] GCC won't treat two compatible function types as compatible if any of them (or both of them) is declared _Noreturn
2022-12-21 11:03 [Bug c/108194] New: GCC won't treat two compatible function types as compatible if any of them (or both of them) is declared _Noreturn pskocik at gmail dot com
` (2 preceding siblings ...)
2022-12-21 17:27 ` joseph at codesourcery dot com
@ 2022-12-21 17:36 ` pinskia at gcc dot gnu.org
2022-12-21 17:48 ` pskocik at gmail dot com
2022-12-22 17:10 ` pskocik at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-21 17:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108194
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Invalid as mentioned in r13-3135-gfa258f6894801a .
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/108194] GCC won't treat two compatible function types as compatible if any of them (or both of them) is declared _Noreturn
2022-12-21 11:03 [Bug c/108194] New: GCC won't treat two compatible function types as compatible if any of them (or both of them) is declared _Noreturn pskocik at gmail dot com
` (3 preceding siblings ...)
2022-12-21 17:36 ` pinskia at gcc dot gnu.org
@ 2022-12-21 17:48 ` pskocik at gmail dot com
2022-12-22 17:10 ` pskocik at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: pskocik at gmail dot com @ 2022-12-21 17:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108194
Petr Skocik <pskocik at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|INVALID |FIXED
--- Comment #5 from Petr Skocik <pskocik at gmail dot com> ---
(In reply to Andrew Pinski from comment #4)
> Invalid as mentioned in r13-3135-gfa258f6894801a .
I believe it's still a bug for pre-c2x __typeof.
While it is GCC's prerogative to include _Noreturn/__attribute((noreturn)) into
the type for its own __typeof (which, BTW, I think is better design than the
standardized semantics), I think two otherwise compatible function types should
still remain compatible if they both either have or don't have
_Noreturn/__attribute((noreturn)). But treating `_Noreturn void NR_FN_A(void);`
as INcompatible with `_Noreturn void NR_FN_B(void);` that's just wonky, IMO.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/108194] GCC won't treat two compatible function types as compatible if any of them (or both of them) is declared _Noreturn
2022-12-21 11:03 [Bug c/108194] New: GCC won't treat two compatible function types as compatible if any of them (or both of them) is declared _Noreturn pskocik at gmail dot com
` (4 preceding siblings ...)
2022-12-21 17:48 ` pskocik at gmail dot com
@ 2022-12-22 17:10 ` pskocik at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: pskocik at gmail dot com @ 2022-12-22 17:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108194
--- Comment #6 from Petr Skocik <pskocik at gmail dot com> ---
(In reply to Petr Skocik from comment #5)
> (In reply to Andrew Pinski from comment #4)
> > Invalid as mentioned in r13-3135-gfa258f6894801a .
>
> I believe it's still a bug for pre-c2x __typeof.
> While it is GCC's prerogative to include _Noreturn/__attribute((noreturn))
> into the type for its own __typeof (which, BTW, I think is better design
> than the standardized semantics), I think two otherwise compatible function
> types should still remain compatible if they both either have or don't have
> _Noreturn/__attribute((noreturn)). But treating `_Noreturn void
> NR_FN_A(void);`
> as INcompatible with `_Noreturn void NR_FN_B(void);` that's just wonky, IMO.
OK, the bug was MINE after all.
For bug report archeologists: I was doing what was meant to be a full
(qualifers-including) type comparison wrong. While something like
_Generic((__typeof(type0)*)0, __typeof(type1)*:1, default:0) suffices to get
around _Generic dropping qualifs (const/volatile/_Atomic) in its controlling
expression, for function pointer types at single pointer layer of indirection,
the _Noreturn attribute will still get dropped in the controlling expression of
_Generic (I guess that makes sense because they're much more closely related to
functions that how another pointer type would be related to its target type)
and another pointer layer of indirection if required as in
`_Generic((__typeof(type0)**)0, __typeof(type1)**:1, default:0)`.
Thanks you all very much, especially joseph@codesourcery.com, who pointed me
(pun intended) to the right solution over email. :)
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-12-22 17:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-21 11:03 [Bug c/108194] New: GCC won't treat two compatible function types as compatible if any of them (or both of them) is declared _Noreturn pskocik at gmail dot com
2022-12-21 13:03 ` [Bug c/108194] " rguenth at gcc dot gnu.org
2022-12-21 13:25 ` pinskia at gcc dot gnu.org
2022-12-21 17:27 ` joseph at codesourcery dot com
2022-12-21 17:36 ` pinskia at gcc dot gnu.org
2022-12-21 17:48 ` pskocik at gmail dot com
2022-12-22 17:10 ` pskocik at gmail dot com
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).