public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Martin Uecker <uecker@tugraz.at>, Andreas Schwab <schwab@suse.de>
Cc: polacek@redhat.com, gcc-patches@gcc.gnu.org
Subject: Re: [gcc15] nested functions in C
Date: Mon, 4 Dec 2023 15:35:07 -0500	[thread overview]
Message-ID: <81ebaa59-ada2-4ba4-b03e-5f7247b2fe5b@gotplt.org> (raw)
In-Reply-To: <90f24d27f63622b90166f43a3648e41c7c911c90.camel@tugraz.at>

On 2023-12-04 13:48, Martin Uecker wrote:
>> I empathize with Jakub's stated use case though of keeping the C
>> frontend support for testing purposes, but that could easily be done
>> behind a flag, or by putting nested C func deprecation behind a flag.
> 
> I am relatively sure C will get some form of nested functions.
> Maybe as anonymous nested functions, i.e. lambdas, but I do
> not see a fundamental difference here (I personally like naming
> things for clarity, so i prefer named nested functions)

If (assuming from them being called lambdas) they are primarily for 
small functions without side-effects then it's already a significantly 
stronger specification than what we have right now with C nested 
functions.  That would end up enforcing what you demonstrate as the good 
way to use nested functions.

I suppose minimal, contained side-effects (such as atomically updating a 
structure) may also constitute sound design, but that should be made 
explicit in the language.

>> I don't disagree for cases like -Warray-bounds,
>> but for warnings/errors that are more deterministic in nature (like
>> -Werror=trampolines), they're going to point at actual problems and
>> larger projects and distributions will usually prefer to at least track
>> them, if not actually fix them.  For Fedora we tend to provide macro
>> overrides for packages that need to explicitly disable a security
>> related flag.
> 
> In projects such as mine, this will lead to a lot of code
> transformations as indicated above, i.e. much worse code.
> 
> One could get away with it, since nested functions are rarely
> used, but I think this is bad, because a lot of code would
> improve if it used them.

If nested functions are eventually going to make it into the C standard 
then effort is probably better spent in porting the C nested functions 
to use descriptors instead of executable stacks or heaps.

Thanks,
Sid

  reply	other threads:[~2023-12-04 20:35 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 [this message]
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
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=81ebaa59-ada2-4ba4-b03e-5f7247b2fe5b@gotplt.org \
    --to=siddhesh@gotplt.org \
    --cc=gcc-patches@gcc.gnu.org \
    --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).