[PATCH 2/3] lib/tests/igt_assert: use volatile cast in igt_assert

Hajda, Andrzej andrzej.hajda at intel.com
Tue Jun 17 15:50:59 UTC 2025


W dniu 17.06.2025 o 16:05, Andrzej Hajda pisze:
> Newer versions of clang optimize code more aggresively.
> As a result change of variable in subtest is observed
> by caller only if it is cast to volatile.
>
> Signed-off-by: Andrzej Hajda <andrzej.hajda at intel.com>


Could be added to description (justification):

According to longjmp specification non-volatile local variables can be 
optimised into registers and longjmp can replace them with other values.


Regards

Andrzej


> ---
>   lib/tests/igt_assert.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/tests/igt_assert.c b/lib/tests/igt_assert.c
> index 3523a46494822cd42f63047c0b5bbb5b39343c84..10c08f9860bb77faa35e4dd46e19d69c94897a7f 100644
> --- a/lib/tests/igt_assert.c
> +++ b/lib/tests/igt_assert.c
> @@ -46,7 +46,7 @@ void (*test_to_run)(void) = NULL;
>    */
>   #define CHECK_NEG(x) { \
>   	igt_subtest_f("XFAIL_simple_%d", __LINE__) { \
> -		(*exec_before)++; \
> +		(*(volatile int *)(exec_before))++; \
>   		x; \
>   		raise(SIGBUS); \
>   	} \
>


More information about the igt-dev mailing list