From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Martin Uecker <uecker@tugraz.at>, Andreas Schwab <schwab@suse.de>,
polacek@redhat.com, gcc-patches@gcc.gnu.org
Subject: Re: [gcc15] nested functions in C
Date: Mon, 4 Dec 2023 15:15:55 -0500 [thread overview]
Message-ID: <5873bf9b-51f6-4db8-a182-86808fa3bb86@gotplt.org> (raw)
In-Reply-To: <ZW4ftvBqvqJyaNJv@tucnak>
On 2023-12-04 13:51, Jakub Jelinek wrote:
> Why? The syntax doesn't seem to be something unexpected, and as C doesn't
> have lambdas, one can use the nested functions instead.
> The only problem is if you need to pass function pointers somewhere else
> (and target doesn't have function descriptors or something similar), if it
> is only done to make code more readable compared to say use of macros, I
> think the nested functions are better, one doesn't have to worry about
> multiple evaluations of argument side-effects etc. And if everything is
> inlined and SRA optimized, there is no extra cost.
> The problem of passing it as a function pointer to other functions is
> common with C++, only lambdas which don't capture anything actually can be
> convertible to function pointer, for anything else you need a template and
> instantiate it for a particular lambda (which is something you can't do in
> C).
I think from a language standpoint, the general idea that nested
functions are just any functions inside functions (which is how the C
nested functions essentially behave) is too broad and they should be
restricted to minimal implementations that, e.g. don't have side-effects
or if they do, there's explicit syntactic sugar to make it clearer.
If (like Martin stated earlier), nested functions are in fact going to
enter the C standard in future then maybe this discussion is moot and we
probably are better off implementing descriptor support for C to replace
the on-stack trampolines instead of adding -Werror=trampolines in a hurry.
Thanks,
Sid
next prev parent reply other threads:[~2023-12-04 20:16 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-01 19:33 [PATCH] gcc: Disallow trampolines when -fhardened Marek Polacek
2023-12-01 19:44 ` Andrew Pinski
2023-12-01 20:53 ` Marek Polacek
2023-12-01 21:14 ` Jakub Jelinek
2023-12-07 15:34 ` Eric Botcazou
2023-12-02 9:42 ` Martin Uecker
2023-12-02 10:24 ` Iain Sandoe
2023-12-04 16:26 ` Siddhesh Poyarekar
2023-12-04 16:39 ` Andreas Schwab
2023-12-04 16:45 ` Jakub Jelinek
2023-12-04 16:46 ` Siddhesh Poyarekar
2023-12-04 17:21 ` Martin Uecker
2023-12-04 18:27 ` [gcc15] nested functions in C Siddhesh Poyarekar
2023-12-04 18:48 ` Martin Uecker
2023-12-04 20:35 ` Siddhesh Poyarekar
2023-12-04 21:31 ` Martin Uecker
2023-12-05 12:32 ` Siddhesh Poyarekar
2023-12-04 21:33 ` Joseph Myers
2023-12-04 22:31 ` Martin Uecker
2023-12-05 21:08 ` Joseph Myers
2023-12-05 21:15 ` Martin Uecker
2023-12-06 7:39 ` Richard Biener
2023-12-04 18:51 ` Jakub Jelinek
2023-12-04 19:13 ` Martin Uecker
2023-12-04 20:15 ` Siddhesh Poyarekar [this message]
2023-12-07 15:42 ` Eric Botcazou
2023-12-07 15:50 ` Siddhesh Poyarekar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5873bf9b-51f6-4db8-a182-86808fa3bb86@gotplt.org \
--to=siddhesh@gotplt.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=polacek@redhat.com \
--cc=schwab@suse.de \
--cc=uecker@tugraz.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).