public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "chenglulu at loongson dot cn" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/105514] New: rv64 qsort gets wrong result when '-O2 -DDEBUG'.
Date: Sat, 07 May 2022 09:56:07 +0000	[thread overview]
Message-ID: <bug-105514-4@http.gcc.gnu.org/bugzilla/> (raw)

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	other threads:[~2022-05-07  9:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-07  9:56 chenglulu at loongson dot cn [this message]
2022-05-07 10:49 ` [Bug target/105514] " pinskia at gcc dot gnu.org
2022-05-09  1:19 ` chenglulu at loongson dot cn
2022-05-09  8:06 ` rguenth at gcc dot gnu.org
2022-05-12  2:10 ` chenglulu at loongson dot cn
2022-05-12  2:29 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105514-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).