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

            Bug ID: 121436
           Summary: Issue seen in gcc/testsuite/jit/test-signed-char.c
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: jit
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
                CC: antoyo at gcc dot gnu.org
  Target Milestone: ---

gcc/testsuite/jit/test-signed-char.c is failing for me on aarch64, ppc64le, and
s390x 

I'm seeing:

  FAIL: test-signed-char.c.exe iteration 1 of 5: verify_code: actual:
test_signed_char () != expected: -2

The test creates the "char" type and then seems to assume that that "char" is
signed; gcc/testsuite/jit.dg/test-signed-char.c has:


  gcc_jit_type *char_type =
    gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_CHAR);

51      CHECK_VALUE (test_signed_char (), -2);
52    }
(gdb) p test_signed_char ()
$1 = 254

but:

Breakpoint 1, build_common_tree_nodes (signed_char=false) at
../../../gcc/tree.cc:9538

so "char" is unsigned on this target.

The test was added in r15-5511-g04b67ac1e8ae4e:

commit 04b67ac1e8ae4e918a804197dfff8e69b0ccf955
Author: Antoni Boucher <boua...@zoho.com>
Date:   Mon Oct 3 19:11:39 2022 -0400
    libgccjit: Support signed char flag

    gcc/jit/ChangeLog:

            * dummy-frontend.cc (jit_langhook_init): Send flag_signed_char
            argument to build_common_tree_nodes.

    gcc/testsuite/ChangeLog:

            * jit.dg/all-non-failing-tests.h: Add test-signed-char.c.
            * jit.dg/test-signed-char.c: New test.


Given that the upstream commit seems to be about respecting the value of
-fsigned-char, I tried adding:

  gcc_jit_context_add_command_line_option (ctxt, "-fsigned-char");

to the test's create_code, but this doesn't seem work; adding:

  gcc_jit_context_set_logfile (ctxt, stderr, 0, 0);

shows that this fails:

JIT:    entering: toplev::main
JIT:     argv[0]: /root/test-signed-char.c.exe
JIT:     argv[1]: /tmp/libgccjit-cq4lLM/fake.c
JIT:     argv[2]: -fPIC
JIT:     argv[3]: -O3
JIT:     argv[4]: -g
JIT:     argv[5]: -quiet
JIT:     argv[6]: --param=ggc-min-expand=0
JIT:     argv[7]: --param=ggc-min-heapsize=0
JIT:     argv[8]: -fdiagnostics-color=never
JIT:     argv[9]: -fsigned-char
test-signed-char.c.exe: warning: command-line option ‘-fsigned-char’ is valid
for Ada/AdaSCIL/AdaWhy/C/C++/LTO/ObjC/ObjC++ but not for 

Antoni: does this test work for you?  Was your intention that
  gcc_jit_context_add_command_line_option (ctxt, "-fsigned-char");
should work?

Reply via email to