public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/100841] New: xtensa-linux: dwarf2cfi.c:291:12: error: comparison of integer expressions of different signedness: 'const unsigned int' and 'int'
@ 2021-05-31  8:04 jbglaw@lug-owl.de
  2021-06-01  8:40 ` [Bug target/100841] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jbglaw@lug-owl.de @ 2021-05-31  8:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100841
           Summary: xtensa-linux: dwarf2cfi.c:291:12: error: comparison of
                    integer expressions of different signedness: 'const
                    unsigned int' and 'int'
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jbglaw@lug-owl.de
  Target Milestone: ---

Hi!

After having started automated testing again, I noticed this as of
ef8176e0fac935c095cc39f4ecdfd43cdb8cb3f3, building with a quite recent GCC:

$ ../gcc/configure --target=xtensa-linux --enable-werror-always
--enable-languages=all --disable-gcov --disable-shared --disable-threads
--without-headers
--prefix=/var/lib/laminar/run/gcc-xtensa-linux/2/toolchain-install

$ make all-gcc
[...]
/usr/lib/gcc-snapshot/bin/g++  -fno-PIE -c   -g -O2 -DIN_GCC 
-DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute
-Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros
-Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I.
-I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include
-I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody 
-I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd
-I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o dwarf2cfi.o -MT
dwarf2cfi.o -MMD -MP -MF ./.deps/dwarf2cfi.TPo ../../gcc/gcc/dwarf2cfi.c
../../gcc/gcc/dwarf2cfi.c: In function 'void init_one_dwarf_reg_size(int,
machine_mode, rtx, machine_mode, init_one_dwarf_reg_state*)':
../../gcc/gcc/dwarf2cfi.c:291:12: error: comparison of integer expressions of
different signedness: 'const unsigned int' and 'int' [-Werror=sign-compare]
  291 |   if (rnum >= DWARF_FRAME_REGISTERS)
cc1plus: all warnings being treated as errors
make[1]: *** [Makefile:1141: dwarf2cfi.o] Error 1
make[1]: Leaving directory
'/var/lib/laminar/run/gcc-xtensa-linux/2/toolchain-build/gcc'
make: *** [Makefile:4414: all-gcc] Error 2

Should be simple to fix I guess.

Thanks,
  Jan-Benedict

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/100841] xtensa-linux: dwarf2cfi.c:291:12: error: comparison of integer expressions of different signedness: 'const unsigned int' and 'int'
  2021-05-31  8:04 [Bug target/100841] New: xtensa-linux: dwarf2cfi.c:291:12: error: comparison of integer expressions of different signedness: 'const unsigned int' and 'int' jbglaw@lug-owl.de
@ 2021-06-01  8:40 ` jakub at gcc dot gnu.org
  2021-06-01 14:11 ` jbglaw@lug-owl.de
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-06-01  8:40 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Guess following could fix it
--- gcc/config/xtensa/xtensa.h.jj       2021-01-04 10:25:45.570157539 +0100
+++ gcc/config/xtensa/xtensa.h  2021-06-01 10:39:19.848827041 +0200
@@ -775,8 +775,9 @@ typedef struct xtensa_args
 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, 0)
 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (0)
 #define DWARF_ALT_FRAME_RETURN_COLUMN 16
-#define DWARF_FRAME_REGISTERS (DWARF_ALT_FRAME_RETURN_COLUMN           \
-                              + (TARGET_WINDOWED_ABI ? 0 : 1))
+#define DWARF_FRAME_REGISTERS \
+  ((unsigned short) (DWARF_ALT_FRAME_RETURN_COLUMN                     \
+                    + (TARGET_WINDOWED_ABI ? 0 : 1)))
 #define EH_RETURN_DATA_REGNO(N) ((N) < 2 ? (N) + 2 : INVALID_REGNUM)
 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL)                     \
   (flag_pic                                                            \
(and make it comparable to both int and unsigned int etc.) without warning,
but no time to verify that.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/100841] xtensa-linux: dwarf2cfi.c:291:12: error: comparison of integer expressions of different signedness: 'const unsigned int' and 'int'
  2021-05-31  8:04 [Bug target/100841] New: xtensa-linux: dwarf2cfi.c:291:12: error: comparison of integer expressions of different signedness: 'const unsigned int' and 'int' jbglaw@lug-owl.de
  2021-06-01  8:40 ` [Bug target/100841] " jakub at gcc dot gnu.org
@ 2021-06-01 14:11 ` jbglaw@lug-owl.de
  2021-06-02 20:10 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jbglaw@lug-owl.de @ 2021-06-01 14:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jan-Benedict Glaw <jbglaw@lug-owl.de> ---
(In reply to Jakub Jelinek from comment #1)
> Guess following could fix it
> --- gcc/config/xtensa/xtensa.h.jj	2021-01-04 10:25:45.570157539 +0100
> +++ gcc/config/xtensa/xtensa.h	2021-06-01 10:39:19.848827041 +0200
[...]

It does, though uncovers the next signedness fun:

[all 2021-06-01 14:06:13] /usr/lib/gcc-snapshot/bin/g++  -fno-PIE -c   -g -O2
-DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute
-Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros
-Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I.
-I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include
-I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody 
-I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd
-I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o function.o -MT
function.o -MMD -MP -MF ./.deps/function.TPo ../../gcc/gcc/function.c
[all 2021-06-01 14:06:14] ../../gcc/gcc/function.c: In function 'void
gen_call_used_regs_seq(rtx_insn*, unsigned int)':
[all 2021-06-01 14:06:14] ../../gcc/gcc/function.c:5897:63: error: comparison
of unsigned expression in '< 0' is always false [-Werror=type-limits]
[all 2021-06-01 14:06:14]  5897 |       if (crtl->uses_only_leaf_regs &&
LEAF_REG_REMAP (regno) < 0)
[all 2021-06-01 14:06:22] cc1plus: all warnings being treated as errors
[all 2021-06-01 14:06:22] make[1]: *** [Makefile:1141: function.o] Error 1
[all 2021-06-01 14:06:22] make[1]: Leaving directory
'/var/lib/laminar/run/gcc-xtensa-linux/4/toolchain-build/gcc'
[all 2021-06-01 14:06:22] make: *** [Makefile:4414: all-gcc] Error 2

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/100841] xtensa-linux: dwarf2cfi.c:291:12: error: comparison of integer expressions of different signedness: 'const unsigned int' and 'int'
  2021-05-31  8:04 [Bug target/100841] New: xtensa-linux: dwarf2cfi.c:291:12: error: comparison of integer expressions of different signedness: 'const unsigned int' and 'int' jbglaw@lug-owl.de
  2021-06-01  8:40 ` [Bug target/100841] " jakub at gcc dot gnu.org
  2021-06-01 14:11 ` jbglaw@lug-owl.de
@ 2021-06-02 20:10 ` cvs-commit at gcc dot gnu.org
  2021-06-03 20:25 ` jbglaw@lug-owl.de
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-02 20:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:50b1de860a58bf85b40a72219bc2fdfaf0dff355

commit r12-1167-g50b1de860a58bf85b40a72219bc2fdfaf0dff355
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jun 2 22:09:53 2021 +0200

    xtensa: Fix 2 warnings during xtensa build [PR100841]

    When building gcc targetting xtensa-linux, there are 2 warnings the PR
    complains about:
    ../../gcc/dwarf2cfi.c: In function âvoid init_one_dwarf_reg_size(int,
machine_mode, rtx, machine_mode, init_one_dwarf_reg_state*)â:
    ../../gcc/dwarf2cfi.c:291:12: warning: comparison of integer expressions of
different signedness: âconst unsigned intâ and âintâ [-Wsign-compare]
      291 |   if (rnum >= DWARF_FRAME_REGISTERS)
    ../../gcc/function.c: In function âvoid gen_call_used_regs_seq(rtx_insn*,
unsigned int)â:
    ../../gcc/function.c:5897:63: warning: comparison of unsigned expression in
â< 0â is always false [-Wtype-limits]
     5897 |       if (crtl->uses_only_leaf_regs && LEAF_REG_REMAP (regno) < 0)
    which might during bootstrap or when configured with --enable-werror-always
    be turned into errors.

    The first one is the -Wsign-compare warning, in c-family we do:
    2281          /* Do not warn if the signed quantity is an unsuffixed
integer
    2282             literal (or some static constant expression involving such
    2283             literals or a conditional expression involving such
literals)
    2284             and it is non-negative.  */
    2285          if (tree_expr_nonnegative_warnv_p (sop, &ovf))
    2286            /* OK */;
    and so don't warn if that function determines the expression is
    non-negative.  But xtensa defines DWARF_FRAME_REGISTERS as
    (16 + (something ? 0 : 1)) and that isn't handled by
    tree_expr_nonnegative_warnv_p, VRP can handle it of course, but that is
much
    later.
    The second chunk rewrites it into a form that tree_expr_nonnegative_warnv_p
    can handle, in particular (something ? 16 : 16 + 1), where for COND_EXPRs
    that function checks both the 2nd and 3rd operand of the ternary operator
    and if both are nonnegative, returns true.

    The other warning has been introduced fairly recently; LEAF_REG_REMAP is
    currently used by 2 targets only, and is documented to yield -1 if a hard
    reg number can't be remapped and the remapped register number otherwise.
    That means that the type of the expression should be signed (otherwise -1
    could never appear), and on SPARC indeed it is defined as
     extern char leaf_reg_remap[];
     #define LEAF_REG_REMAP(REGNO) (leaf_reg_remap[REGNO])
    so unless the host is -funsigned-char by default it works fine.
    I guess sparc.[ch] should be fixed to use signed char of leaf_reg_remap,
    Eric?
    The argument to LEAF_REG_REMAP is often unsigned int though, hard
    register numbers are usually not negative, and thus the warning.
    I think xtensa doesn't have 2G hard registers and so it is ok to just cast
    it to int.

    2021-06-02  Jakub Jelinek  <jakub@redhat.com>

            PR target/100841
            * config/xtensa/xtensa.h (LEAF_REG_REMAP): Cast REGNO to int to
avoid
            -Wtype-limits warnings.
            (DWARF_FRAME_REGISTER): Rewrite into ternary operator with addition
            in operands to avoid -Wsign-compare warnings.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/100841] xtensa-linux: dwarf2cfi.c:291:12: error: comparison of integer expressions of different signedness: 'const unsigned int' and 'int'
  2021-05-31  8:04 [Bug target/100841] New: xtensa-linux: dwarf2cfi.c:291:12: error: comparison of integer expressions of different signedness: 'const unsigned int' and 'int' jbglaw@lug-owl.de
                   ` (2 preceding siblings ...)
  2021-06-02 20:10 ` cvs-commit at gcc dot gnu.org
@ 2021-06-03 20:25 ` jbglaw@lug-owl.de
  2021-06-03 20:25 ` jbglaw@lug-owl.de
  2021-09-17  6:45 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jbglaw@lug-owl.de @ 2021-06-03 20:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jan-Benedict Glaw <jbglaw@lug-owl.de> ---
Builds now. Thanks a lot!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/100841] xtensa-linux: dwarf2cfi.c:291:12: error: comparison of integer expressions of different signedness: 'const unsigned int' and 'int'
  2021-05-31  8:04 [Bug target/100841] New: xtensa-linux: dwarf2cfi.c:291:12: error: comparison of integer expressions of different signedness: 'const unsigned int' and 'int' jbglaw@lug-owl.de
                   ` (3 preceding siblings ...)
  2021-06-03 20:25 ` jbglaw@lug-owl.de
@ 2021-06-03 20:25 ` jbglaw@lug-owl.de
  2021-09-17  6:45 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jbglaw@lug-owl.de @ 2021-06-03 20:25 UTC (permalink / raw)
  To: gcc-bugs

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

Jan-Benedict Glaw <jbglaw@lug-owl.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Jan-Benedict Glaw <jbglaw@lug-owl.de> ---
Fixed by Jakub Jelinek.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/100841] xtensa-linux: dwarf2cfi.c:291:12: error: comparison of integer expressions of different signedness: 'const unsigned int' and 'int'
  2021-05-31  8:04 [Bug target/100841] New: xtensa-linux: dwarf2cfi.c:291:12: error: comparison of integer expressions of different signedness: 'const unsigned int' and 'int' jbglaw@lug-owl.de
                   ` (4 preceding siblings ...)
  2021-06-03 20:25 ` jbglaw@lug-owl.de
@ 2021-09-17  6:45 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-17  6:45 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-17  6:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-31  8:04 [Bug target/100841] New: xtensa-linux: dwarf2cfi.c:291:12: error: comparison of integer expressions of different signedness: 'const unsigned int' and 'int' jbglaw@lug-owl.de
2021-06-01  8:40 ` [Bug target/100841] " jakub at gcc dot gnu.org
2021-06-01 14:11 ` jbglaw@lug-owl.de
2021-06-02 20:10 ` cvs-commit at gcc dot gnu.org
2021-06-03 20:25 ` jbglaw@lug-owl.de
2021-06-03 20:25 ` jbglaw@lug-owl.de
2021-09-17  6:45 ` pinskia at gcc dot gnu.org

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).