From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Schwab Date: Wed, 24 Mar 2021 10:18:28 +0100 Subject: [PATCH v2 2/2] test: unit test for longjmp In-Reply-To: <90e8d095-9a0a-2524-131c-49e79a47aa08@gmail.com> (Sean Anderson's message of "Mon, 22 Mar 2021 09:30:41 -0400") References: <20210322110249.4387-1-xypron.glpk@gmx.de> <20210322110249.4387-3-xypron.glpk@gmx.de> <47007446-5ad9-c5b2-dc55-78400f288dc5@gmail.com> <90e8d095-9a0a-2524-131c-49e79a47aa08@gmail.com> Message-ID: <875z1goqor.fsf@igel.home> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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."