[Bug middle-end/31377] wrap_help error

2026-04-09 Thread heiko at hexco dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31377

Heiko Eißfeldt  changed:

   What|Removed |Added

 CC||heiko at hexco dot de

--- Comment #4 from Heiko Eißfeldt  ---
I think the reporter was assuming the subtraction was done with signed ints, so
the following comparison looked incorrect at first glance.
But since all involved variables are of type unsigned int, the comparison is
correct IMHO, although not easily readable/understandable.

Anyway, since "room" cannot be smaller than 0, the proposed "fix" would not
compile.

Since this bug was confirmed and even the author was assuming an error in the
comparison, maybe it should be either changed to signed ints (to make the code
better understandable) or the "underflow" should be avoided. Then it could be
expressed like this:
```cpp
diff --git a/gcc/opts.cc b/gcc/opts.cc
index 6658b6acd37..fb3a9a7cf83 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -1624,9 +1624,11 @@ wrap_help (const char *help,

   do
 {
-  room = columns - 3 - MAX (col_width, item_width);
-  if (room > columns)
+  if (columns > 3 + MAX (col_width, item_width))
+   room = columns - 3 - MAX (col_width, item_width);
+  else
room = 0;
+
   len = remaining;

   if (room < len)
```

I can sent this as a patch, if this rather cosmetic change is wanted.
In any case this PR seems to be no real bug to me (and could be closed).

[Bug middle-end/31377] wrap_help error

2018-11-15 Thread nickc at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31377

--- Comment #3 from Nick Clifton  ---
Hi George,

(In reply to George Ellery from comment #0)

>   room = columns - 3 - MAX (col_width, item_width);
>   if (room > columns)

>   room = columns - 3 - MAX (col_width, item_width);
>   if (room < 0)

Doh!  Yes this was my mistake.  I do not have approval rights
to this code, but personally I would consider your fix as "obvious"
and so hope that it can be committed without much fuss.

Cheers
  Nick

[Bug middle-end/31377] wrap_help error

2018-11-14 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31377

Eric Gallager  changed:

   What|Removed |Added

 CC||nickc at gcc dot gnu.org

--- Comment #2 from Eric Gallager  ---
svn blame says nickc wrote this code in r121849; cc-ing him

[Bug middle-end/31377] wrap_help error

2017-09-26 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31377

Eric Gallager  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-09-27
 CC||egallager at gcc dot gnu.org
 Ever confirmed|0   |1
   Severity|minor   |trivial

--- Comment #1 from Eric Gallager  ---
Confirmed that wrap_help in gcc/opts.c still has the code in question; please
submit a patch to the gcc-patches mailing list for review.