[PATCH v2 2/2] test: unit test for longjmp

Andreas Schwab schwab at linux-m68k.org
Wed Mar 24 10:18:28 CET 2021


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."


More information about the U-Boot mailing list