Skip to content

Commit 027be4b

Browse files
sunyuechipablodelara
authored andcommitted
add volatile for igzip/checksum32_funs_test
When using RISC-V GCC 14, `gcc -O0` passes the test, but `gcc -O2` fails. The log shows that it enters the branch `if (c_dut != c_ref) {` even though `c_dut` and `c_ref` have the same value. Adding `volatile` allows the test to pass. Signed-off-by: sunyuechi <[email protected]>
1 parent e0687d4 commit 027be4b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

igzip/checksum32_funcs_test.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ main(int argc, char *argv[])
126126
int
127127
zeros_test(func_case_t *test_func)
128128
{
129-
uint32_t c_dut, c_ref;
129+
volatile uint32_t c_dut, c_ref;
130130
int fail = 0;
131131
unsigned char *buf = NULL;
132132

@@ -153,7 +153,7 @@ zeros_test(func_case_t *test_func)
153153
int
154154
simple_pattern_test(func_case_t *test_func)
155155
{
156-
uint32_t c_dut, c_ref;
156+
volatile uint32_t c_dut, c_ref;
157157
int fail = 0;
158158
unsigned char *buf = NULL;
159159

@@ -176,7 +176,7 @@ simple_pattern_test(func_case_t *test_func)
176176
int
177177
seeds_sizes_test(func_case_t *test_func)
178178
{
179-
uint32_t c_dut, c_ref;
179+
volatile uint32_t c_dut, c_ref;
180180
int fail = 0;
181181
int i;
182182
uint32_t r, s;
@@ -251,7 +251,7 @@ seeds_sizes_test(func_case_t *test_func)
251251
int
252252
eob_test(func_case_t *test_func)
253253
{
254-
uint32_t c_dut, c_ref;
254+
volatile uint32_t c_dut, c_ref;
255255
int fail = 0;
256256
int i;
257257
unsigned char *buf = NULL;
@@ -277,7 +277,7 @@ eob_test(func_case_t *test_func)
277277
int
278278
update_test(func_case_t *test_func)
279279
{
280-
uint32_t c_dut, c_ref;
280+
volatile uint32_t c_dut, c_ref;
281281
int fail = 0;
282282
int i;
283283
uint32_t r;
@@ -310,7 +310,7 @@ update_test(func_case_t *test_func)
310310
int
311311
update_over_mod_test(func_case_t *test_func)
312312
{
313-
uint32_t c_dut, c_ref;
313+
volatile uint32_t c_dut, c_ref;
314314
int fail = 0;
315315
int i;
316316
unsigned char *buf = NULL;

0 commit comments

Comments
 (0)