public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102440] New: Uinteger Opt/Param but the underlying type is signed
@ 2021-09-22  3:11 linkw at gcc dot gnu.org
  2021-09-22  3:13 ` [Bug middle-end/102440] " linkw at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: linkw at gcc dot gnu.org @ 2021-09-22  3:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102440
           Summary: Uinteger Opt/Param but the underlying type is signed
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: linkw at gcc dot gnu.org
  Target Milestone: ---

The UInteger type in Opt/Param declaration can easily confuse people that the
variable for this option/parameter is unsigned.  But actually the internal
implementation uses signed for it, it requires users to add explicit type
conversion for some cases, otherwise the bootstrapping fails due to -Werror.
I guess the "UInteger" is mainly to restrict the value range of
option/parameter.  But I think we still can improve it? Like using one
anonymous union with uinteger and integer instead of a single integer, then
name the corresponding member as signedness?

File this as Segher's suggestion from patch reviewing.

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

* [Bug middle-end/102440] Uinteger Opt/Param but the underlying type is signed
  2021-09-22  3:11 [Bug tree-optimization/102440] New: Uinteger Opt/Param but the underlying type is signed linkw at gcc dot gnu.org
@ 2021-09-22  3:13 ` linkw at gcc dot gnu.org
  2021-09-22  5:47 ` [Bug other/102440] " pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: linkw at gcc dot gnu.org @ 2021-09-22  3:13 UTC (permalink / raw)
  To: gcc-bugs

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

Kewen Lin <linkw at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |segher at gcc dot gnu.org
           Severity|normal                      |enhancement
          Component|tree-optimization           |middle-end

--- Comment #1 from Kewen Lin <linkw at gcc dot gnu.org> ---
Not sure which component I should mark this with, put middle-end temporarily.

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

* [Bug other/102440] Uinteger Opt/Param but the underlying type is signed
  2021-09-22  3:11 [Bug tree-optimization/102440] New: Uinteger Opt/Param but the underlying type is signed linkw at gcc dot gnu.org
  2021-09-22  3:13 ` [Bug middle-end/102440] " linkw at gcc dot gnu.org
@ 2021-09-22  5:47 ` pinskia at gcc dot gnu.org
  2021-09-23  6:23 ` linkw at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-22  5:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|middle-end                  |other

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The other option handling bug report I saw dealing with the awk script was
recorded as other.

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

* [Bug other/102440] Uinteger Opt/Param but the underlying type is signed
  2021-09-22  3:11 [Bug tree-optimization/102440] New: Uinteger Opt/Param but the underlying type is signed linkw at gcc dot gnu.org
  2021-09-22  3:13 ` [Bug middle-end/102440] " linkw at gcc dot gnu.org
  2021-09-22  5:47 ` [Bug other/102440] " pinskia at gcc dot gnu.org
@ 2021-09-23  6:23 ` linkw at gcc dot gnu.org
  2021-09-27 13:29 ` marxin at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: linkw at gcc dot gnu.org @ 2021-09-23  6:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Kewen Lin <linkw at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> The other option handling bug report I saw dealing with the awk script was
> recorded as other.

Thanks Andrew!  I just found there is a "other", how blind I am!

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

* [Bug other/102440] Uinteger Opt/Param but the underlying type is signed
  2021-09-22  3:11 [Bug tree-optimization/102440] New: Uinteger Opt/Param but the underlying type is signed linkw at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-09-23  6:23 ` linkw at gcc dot gnu.org
@ 2021-09-27 13:29 ` marxin at gcc dot gnu.org
  2021-10-25 15:00 ` marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-09-27 13:29 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-09-27
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
I can try working on that.

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

* [Bug other/102440] Uinteger Opt/Param but the underlying type is signed
  2021-09-22  3:11 [Bug tree-optimization/102440] New: Uinteger Opt/Param but the underlying type is signed linkw at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-09-27 13:29 ` marxin at gcc dot gnu.org
@ 2021-10-25 15:00 ` marxin at gcc dot gnu.org
  2021-10-25 20:53 ` segher at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-10-25 15:00 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|marxin at gcc dot gnu.org          |unassigned at gcc dot gnu.org
             Status|ASSIGNED                    |NEW

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
All right, so the meaning of the UInteger type is actually that users can't set
the flag/param to a negative value:

$ gcc -fabi-version=-3 a.c
gcc: error: argument to '-fabi-version=' should be a non-negative integer

Plus there are very many flags that are initialized to -1 with Init(-1). The
special value is used for distinguishing between a set value and the default
one.

So the name is unfortunate, but I don't see what can we do about it?

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

* [Bug other/102440] Uinteger Opt/Param but the underlying type is signed
  2021-09-22  3:11 [Bug tree-optimization/102440] New: Uinteger Opt/Param but the underlying type is signed linkw at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-10-25 15:00 ` marxin at gcc dot gnu.org
@ 2021-10-25 20:53 ` segher at gcc dot gnu.org
  2021-10-25 21:14 ` segher at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: segher at gcc dot gnu.org @ 2021-10-25 20:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Segher Boessenkool <segher at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #5)
> All right, so the meaning of the UInteger type is actually that users can't
> set the flag/param to a negative value:
> 
> $ gcc -fabi-version=-3 a.c
> gcc: error: argument to '-fabi-version=' should be a non-negative integer

That doesn't contradict using it with an "unsigned int".

> Plus there are very many flags that are initialized to -1 with Init(-1). The
> special value is used for distinguishing between a set value and the default
> one.

That doesn't contradict using it with an "unsigned int".

> So the name is unfortunate, but I don't see what can we do about it?

We could make the "UInteger" type mean it is implemented with an "unsigned int"
C type (or some other unsigned integer type).

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

* [Bug other/102440] Uinteger Opt/Param but the underlying type is signed
  2021-09-22  3:11 [Bug tree-optimization/102440] New: Uinteger Opt/Param but the underlying type is signed linkw at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-10-25 20:53 ` segher at gcc dot gnu.org
@ 2021-10-25 21:14 ` segher at gcc dot gnu.org
  2021-10-26 15:17 ` marxin at gcc dot gnu.org
  2021-10-26 16:45 ` segher at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: segher at gcc dot gnu.org @ 2021-10-25 21:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Segher Boessenkool <segher at gcc dot gnu.org> ---
The documentation for UInteger also says

  Positive values of the argument in
  excess of @code{INT_MAX} wrap around zero.

so C "unsigned" types are natural for it.

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

* [Bug other/102440] Uinteger Opt/Param but the underlying type is signed
  2021-09-22  3:11 [Bug tree-optimization/102440] New: Uinteger Opt/Param but the underlying type is signed linkw at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-10-25 21:14 ` segher at gcc dot gnu.org
@ 2021-10-26 15:17 ` marxin at gcc dot gnu.org
  2021-10-26 16:45 ` segher at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-10-26 15:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Segher Boessenkool from comment #6)
> (In reply to Martin Liška from comment #5)
> > All right, so the meaning of the UInteger type is actually that users can't
> > set the flag/param to a negative value:
> > 
> > $ gcc -fabi-version=-3 a.c
> > gcc: error: argument to '-fabi-version=' should be a non-negative integer
> 
> That doesn't contradict using it with an "unsigned int".

Yes.

> 
> > Plus there are very many flags that are initialized to -1 with Init(-1). The
> > special value is used for distinguishing between a set value and the default
> > one.
> 
> That doesn't contradict using it with an "unsigned int".

Yes.

> 
> > So the name is unfortunate, but I don't see what can we do about it?
> 
> We could make the "UInteger" type mean it is implemented with an "unsigned
> int"
> C type (or some other unsigned integer type).

This would lead to the following list of -Wsign-compare warnings:

/home/marxin/Programming/gcc/gcc/c-family/c-opts.c:934:27: warning: comparison
of integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/c-family/c-opts.c:988:57: warning: comparison
of integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/c-family/c-opts.c:990:36: warning: comparison
of integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/c-family/c-opts.c:992:62: warning: comparison
of integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/auto-profile.c:1631:23: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cfgcleanup.c:2012:15: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cfgexpand.c:6805:7: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/combine.c:13151:36: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cse.c:6315:30: warning: comparison of integer
expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cse.c:6493:30: warning: comparison of integer
expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cselib.c:2507:24: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/emit-rtl.c:2731:29: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/emit-rtl.c:3403:26: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/emit-rtl.c:4011:26: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/flags.h:111:64: warning: comparison of integer
expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/fold-const.c:6030:42: warning: comparison of
integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/fold-const.c:9670:42: warning: comparison of
integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/fold-const.c:14686:24: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/fold-const.c:15346:24: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/gcse.c:801:20: warning: comparison of integer
expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/gcse.c:1846:43: warning: comparison of integer
expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/gimple-loop-interchange.cc:369:23: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/gimple-loop-interchange.cc:2034:36: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/gimple-range-cache.cc:437:42: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/gimple-range-gori.cc:348:31: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/gimple-ssa-split-paths.c:413:7: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/haifa-sched.c:5160:47: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/haifa-sched.c:5164:41: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/haifa-sched.c:6573:40: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ifcvt.c:3946:9: warning: comparison of integer
expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ipa-cp.c:2066:45: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ipa-cp.c:1942:43: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ipa-cp.c:1942:43: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ipa-inline.c:187:18: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ipa-inline.c:603:22: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ipa-inline.c:732:34: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ipa-inline.c:923:18: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ipa-inline.c:943:26: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ipa-inline.c:1783:17: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ipa-inline.c:3022:25: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ipa-inline.c:3042:26: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ipa-modref.c:1500:36: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ipa-modref.c:1671:13: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ipa-prop.c:1250:17: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/ira-build.c:2254:17: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/loop-invariant.c:1493:15: warning: comparison
of integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/loop-unroll.c:1816:37: warning: comparison of
integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/lra-constraints.c:6911:56: warning: comparison
of integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/system.h:395:23: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/modulo-sched.c:1657:27: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
options-save.c:11902:10: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
options-save.c:11927:10: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
options-save.c:12081:10: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
options-save.c:12877:10: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
options-save.c:12896:10: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
options-save.c:13013:10: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/predict.c:447:8: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/predict.c:449:11: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/reload.c:6731:18: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/sched-rgn.c:571:21: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/sched-rgn.c:572:26: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/sched-deps.c:2483:15: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/sched-deps.c:2685:17: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/sched-deps.c:3210:41: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/sched-deps.c:3211:48: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/sched-rgn.c:2226:20: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/sched-deps.c:3667:44: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/sched-rgn.c:3188:23: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/sel-sched-ir.c:6024:26: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/sel-sched.c:3456:11: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/sanopt.c:1307:26: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-chrec.c:335:25: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-chrec.c:337:27: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-data-ref.c:5710:7: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-inline.c:1842:15: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-scalar-evolution.c:1151:17: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-scalar-evolution.c:2625:19: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-ifcombine.c:569:50: warning:
comparison of integer expressions of different signedness: ‘unsigned int’ and
‘int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-dse.c:699:17: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-dse.c:810:21: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-loop-ivcanon.c:863:20: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-loop-ivcanon.c:1069:7: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-loop-ivcanon.c:1504:25: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-loop-split.c:1424:52: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-loop-unswitch.c:324:22: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-loop-unswitch.c:353:20: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-loop-prefetch.c:1826:25: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-loop-prefetch.c:1863:30: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-strlen.c:706:18: warning: comparison
of integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-strlen.c:735:18: warning: comparison
of integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-threadbackward.c:776:19: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/tree-ssa-threadedge.c:268:15: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/var-tracking.c:5912:20: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/var-tracking.c:8438:32: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/analyzer/analysis-plan.cc:133:7: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/analyzer/program-point.cc:440:13: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/analyzer/engine.cc:2434:7: warning: comparison
of integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/analyzer/engine.cc:3129:11: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cp/constraint.cc:3746:42: warning: comparison
of integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cp/constexpr.c:1721:11: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cp/constexpr.c:2689:24: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cp/constexpr.c:5996:19: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cp/decl.c:4587:29: warning: comparison of
integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cp/decl.c:4762:41: warning: comparison of
integer expressions of different signedness: ‘unsigned int’ and ‘const int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cp/decl.c:4773:37: warning: comparison of
integer expressions of different signedness: ‘unsigned int’ and ‘const int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cp/decl.c:4779:42: warning: comparison of
integer expressions of different signedness: ‘unsigned int’ and ‘const int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cp/decl.c:4783:44: warning: comparison of
integer expressions of different signedness: ‘unsigned int’ and ‘const int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cp/decl.c:4791:37: warning: comparison of
integer expressions of different signedness: ‘unsigned int’ and ‘const int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cp/error.c:3705:18: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/cp/mangle.c:4132:39: warning: comparison of
integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/flags.h:108:46: warning: comparison of integer
expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/flags.h:108:46: warning: comparison of integer
expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/fortran/expr.c:1710:17: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/fortran/options.c:291:58: warning: comparison
of integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/fortran/options.c:420:50: warning: comparison
of integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/fortran/options.c:430:36: warning: comparison
of integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/fortran/options.c:433:36: warning: comparison
of integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/fortran/options.c:443:31: warning: comparison
of integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/fortran/options.c:455:31: warning: comparison
of integer expressions of different signedness: ‘unsigned int’ and ‘int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/fortran/simplify.c:7845:13: warning:
comparison of integer expressions of different signedness: ‘int’ and ‘unsigned
int’ [-Wsign-compare]
/home/marxin/Programming/gcc/gcc/lto/lto.c:445:27: warning: comparison of
integer expressions of different signedness: ‘int’ and ‘unsigned int’
[-Wsign-compare]
/home/marxin/Programming/gcc/gcc/lto/lto-partition.c:534:32: warning:
comparison of integer expressions of different signedness: ‘unsigned int’ and
‘int’ [-Wsign-compare]

One would need to verify/adjust all these places (plus many more for other
targets).

I'm not sure it's worth it. Unassigning myself..

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

* [Bug other/102440] Uinteger Opt/Param but the underlying type is signed
  2021-09-22  3:11 [Bug tree-optimization/102440] New: Uinteger Opt/Param but the underlying type is signed linkw at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-10-26 15:17 ` marxin at gcc dot gnu.org
@ 2021-10-26 16:45 ` segher at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: segher at gcc dot gnu.org @ 2021-10-26 16:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Segher Boessenkool <segher at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #8)
> > We could make the "UInteger" type mean it is implemented with an "unsigned
> > int"
> > C type (or some other unsigned integer type).
> 
> This would lead to the following list of -Wsign-compare warnings:
> 
> /home/marxin/Programming/gcc/gcc/c-family/c-opts.c:934:27: warning:
> comparison of integer expressions of different signedness: ‘unsigned int’
> and ‘int’ [-Wsign-compare]

That line is

  if (warn_shift_overflow == -1)

The documentation for that warning flag says
'-Wsign-compare'
     Warn when a comparison between signed and unsigned values could
     produce an incorrect result when the signed value is converted to
     unsigned.  In C++, this warning is also enabled by '-Wall'.  In C,
     it is also enabled by '-Wextra'.

I don't see how this could produce an incorrect result.  Writing the code as

  if (warn_shift_overflow == -1U)

means exactly the same thing, except it assumes the size of the variable so
it is a bad habit.  Plain "-1" is easier to read anyway.

It is idiom to use -1 for all-bits-set for unsigned vars.  It works correctly
whatever the size of the variable is.  It is silly if

  if (warn_shift_overflow == -1)

warns, but

  if (warn_shift_overflow + 1 == 0)

is just dandy (and that is the current situation :-( )

> One would need to verify/adjust all these places (plus many more for other
> targets).

Or fix the bloody warning ;-)  But not something you want on your plate, I
fully
understand :-)

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

end of thread, other threads:[~2021-10-26 16:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22  3:11 [Bug tree-optimization/102440] New: Uinteger Opt/Param but the underlying type is signed linkw at gcc dot gnu.org
2021-09-22  3:13 ` [Bug middle-end/102440] " linkw at gcc dot gnu.org
2021-09-22  5:47 ` [Bug other/102440] " pinskia at gcc dot gnu.org
2021-09-23  6:23 ` linkw at gcc dot gnu.org
2021-09-27 13:29 ` marxin at gcc dot gnu.org
2021-10-25 15:00 ` marxin at gcc dot gnu.org
2021-10-25 20:53 ` segher at gcc dot gnu.org
2021-10-25 21:14 ` segher at gcc dot gnu.org
2021-10-26 15:17 ` marxin at gcc dot gnu.org
2021-10-26 16:45 ` segher 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).