Skip to content

Commit

Permalink
Eliminate 'x might be clobbered by longjmp' gcc warning in setjmp_t.c
Browse files Browse the repository at this point in the history
* tools/setjmp_t.c [!__cplusplus || __cplusplus<201703] (main): Do not
use "register" for x local variable if compiling by gcc (or clang) with
-O0 flag.
  • Loading branch information
ivmai committed May 3, 2024
1 parent 449cf96 commit b1fe062
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/setjmp_t.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ int main(void)
unsigned ps = GETPAGESIZE();
# ifndef WASI
JMP_BUF b;
# if !defined(__cplusplus) || __cplusplus < 201703L /* before c++17 */
# if (!defined(__cplusplus) || __cplusplus < 201703L /* before c++17 */) \
&& (!defined(__GNUC__) || defined(__OPTIMIZE__))
register
# endif
int x = (int)strlen(a_str); /* 1, slightly disguised */
Expand Down

0 comments on commit b1fe062

Please sign in to comment.