[PATCH 07/19] commands: ubsan: hide pointer provenance used to trigger UB

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Jun 12 06:02:28 PDT 2023


The ubsan command invokes various sort of undefined behavior to verify
that the Undefined Behavior Sanitizer works as expected. Compiler warns
about some of this, which is not helpful, so work around the warning.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 commands/ubsan.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/commands/ubsan.c b/commands/ubsan.c
index 620b4774c3c2..4a9716139c4b 100644
--- a/commands/ubsan.c
+++ b/commands/ubsan.c
@@ -102,6 +102,8 @@ static void test_ubsan_object_size_mismatch(void)
 	volatile long long *ptr, val2;
 
 	ptr = (long long *)&val;
+	OPTIMIZER_HIDE_VAR(ptr);
+
 	val2 = *ptr;
 }
 
-- 
2.39.2




More information about the barebox mailing list