https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105514

            Bug ID: 105514
           Summary: rv64 qsort gets wrong result when '-O2 -DDEBUG'.
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chenglulu at loongson dot cn
  Target Milestone: ---

Created attachment 52936
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52936&action=edit
riscv64-linux-gnu

%riscv64-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=riscv64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/.../libexec/gcc/riscv64-linux-gnu/13.0.0/lto-wrapper
Target: riscv64-linux-gnu
Configured with: /.../configure --target=riscv64-linux-gnu --with-arch=rv64g
--with-abi=lp64d --enable-shared --disable-emultls --disable-bootstrap
--enable-languages=c,c++,fortran --disable-multilib 
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.0.0 20220507 (experimental) (GCC) 

There is no problem with the execution result of the following compiler.
% riscv64-linux-gnu-gcc qsort.c -o qsort -O2 --static -march=rv64g -mabi=lp64d
% ./qsort
./qsort 

But, When I add a line to the code to print,program execution result is wrong.
% riscv64-linux-gnu-gcc qsort.c -o qsort -O2 --static -march=rv64g -mabi=lp64d
-DDEBUG
./qsort 





test simple_qsort array with function pointer failed.

When add option '-DDEBUG -fno-reorder-blocks', The program execution result is
no problem again.

Reply via email to