Fix note_defect3 function

Message ID CAPzzfctOqwsbG4ig4gT2eUWc5C+YdLZPJfKtHDgN8OKSQU+PzA@mail.gmail.com
State Accepted
Headers
Series Fix note_defect3 function |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Akari Takahashi June 13, 2023, 3:18 a.m. UTC
  Hello,

I've noticed an issue with the note_defect3 function and have prepared a
patch to fix it. The function is missing a return statement, which is
causing undefined behavior. This patch adds the missing return statement,
ensuring that the function returns the correct value.

Please consider applying this patch to correct the issue. Thank you.

Best regards,

Takahashi Akari

---
---
  

Comments

Jeff Law June 13, 2023, 1:50 p.m. UTC | #1
On 6/12/23 21:18, Akari Takahashi via Gcc-patches wrote:
> Hello,
> 
> I've noticed an issue with the note_defect3 function and have prepared a
> patch to fix it. The function is missing a return statement, which is
> causing undefined behavior. This patch adds the missing return statement,
> ensuring that the function returns the correct value.
> 
> Please consider applying this patch to correct the issue. Thank you.
> 
> Best regards,
> 
> Takahashi Akari
Thanks.  Reviewing that file it looks like it was just supposed to be 
used for the sh5/sh5media processor.  My recollection is those were 
never actually produced and support for them was removed from GCC some 
time ago.  This file was missed during that removal.

Rather than apply the patch, I think the better choice is to just remove 
the divtab.cc file unless someone has a real use for it.

Is there a particular reason you were investigating the divtab.cc file?

jeff
  
Akari Takahashi June 13, 2023, 7:13 p.m. UTC | #2
Hi Jeff,

Thank you for your response. Regarding the divtab.cc file, I actually came
across it by accident while working on another task. I didn't have a
specific reason for investigating the file, but I noticed the issue and
thought it was worth bringing to your attention.

Thank you for taking care of this issue.

Best Regards,

Takahashi Akari

On Tue, Jun 13, 2023 at 10:50 PM Jeff Law <jeffreyalaw@gmail.com> wrote:

>
>
> On 6/12/23 21:18, Akari Takahashi via Gcc-patches wrote:
> > Hello,
> >
> > I've noticed an issue with the note_defect3 function and have prepared a
> > patch to fix it. The function is missing a return statement, which is
> > causing undefined behavior. This patch adds the missing return statement,
> > ensuring that the function returns the correct value.
> >
> > Please consider applying this patch to correct the issue. Thank you.
> >
> > Best regards,
> >
> > Takahashi Akari
> Thanks.  Reviewing that file it looks like it was just supposed to be
> used for the sh5/sh5media processor.  My recollection is those were
> never actually produced and support for them was removed from GCC some
> time ago.  This file was missed during that removal.
>
> Rather than apply the patch, I think the better choice is to just remove
> the divtab.cc file unless someone has a real use for it.
>
> Is there a particular reason you were investigating the divtab.cc file?
>
> jeff
>
  

Patch

diff --git a/gcc/config/sh/divtab.cc b/gcc/config/sh/divtab.cc
index 30d57f2a1dd..cd3e709e3ab 100644
--- a/gcc/config/sh/divtab.cc
+++ b/gcc/config/sh/divtab.cc
@@ -75,12 +75,13 @@  note_defect3 (int val, double d2, double y2d, double x)
   if (defect < min_defect3)
     {
       min_defect3 = defect;
       min_defect3_x = x;
       min_defect3_val = val;
     }
+  return defect;
 }

 /* This function assumes 32-bit integers.  */
 static double
 calc_defect (double x, int constant, int factor)
 {