public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@linux-m68k.org>
To: u-boot@lists.denx.de
Subject: [PATCH v2 2/2] test: unit test for longjmp
Date: Wed, 24 Mar 2021 10:18:28 +0100	[thread overview]
Message-ID: <875z1goqor.fsf@igel.home> (raw)
In-Reply-To: <90e8d095-9a0a-2524-131c-49e79a47aa08@gmail.com> (Sean Anderson's message of "Mon, 22 Mar 2021 09:30:41 -0400")

On M?r 22 2021, Sean Anderson wrote:

> int test_longjmp_ret(int i)
> {
>      jmp_buf env;
>      int ret;
>      int foo = i;
>
>      ret = setjmp(env);
>      if (ret)
>          return foo;
>      foo = 0x1000;
>      longjmp(env, i);
>      /* We should not arrive here */
>      return foo;

This is undefined.  When modifying a non-volatile auto variable between
setjmp and longjmp, there is no requirement that the value is preserved.

Andreas.

-- 
Andreas Schwab, schwab at linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

  parent reply	other threads:[~2021-03-24  9:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22 11:02 [PATCH v2 0/2] riscv: simplify longjmp Heinrich Schuchardt
2021-03-22 11:02 ` [PATCH v2 1/2] " Heinrich Schuchardt
2021-03-22 12:53   ` Sean Anderson
2021-03-23 11:54   ` Leo Liang
2021-03-22 11:02 ` [PATCH v2 2/2] test: unit test for longjmp Heinrich Schuchardt
2021-03-22 13:23   ` Sean Anderson
2021-03-22 13:30     ` Sean Anderson
2021-03-22 16:42       ` Heinrich Schuchardt
2021-03-23 13:30         ` Sean Anderson
2021-03-24  9:18       ` Andreas Schwab [this message]
2021-03-24 11:16         ` Heinrich Schuchardt
2021-03-24 12:39           ` Andreas Schwab
2021-03-24 13:28             ` Heinrich Schuchardt

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=875z1goqor.fsf@igel.home \
    --to=schwab@linux-m68k.org \
    --cc=u-boot@lists.denx.de \
    /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