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

--- Comment #4 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Martin Liška from comment #3)
> I've briefly looked at the issue and I don't know a configuration that uses
> libdecnumber. So I'm leaving that..

I just checked my latest build of trunk gcc on x86_64 and I got:

$ fgrep -c libdecnumber mk.out 
613
$ 

I think it would be sufficient to move local variable "buffer" out
to a wider scope.

Something like:

$ svn diff decCommon.c
Index: decCommon.c
===================================================================
--- decCommon.c (revision 266300)
+++ decCommon.c (working copy)
@@ -427,6 +427,8 @@

     /* if exponent is >=emax may have to clamp, overflow, or fold-down */
     if (num->exponent>DECEMAX-(DECPMAX-1)) { /* is edge case */
+      uByte buffer[ROUNDUP(DECPMAX+3, 4)]; /* [+3 allows uInt padding] */
+
       /* printf("overflow checks...\n"); */
       if (*ulsd==0 && ulsd==umsd) {    /* have zero */
        num->exponent=DECEMAX-(DECPMAX-1); /* clamp to max */
@@ -468,7 +470,6 @@
          /* fold down needed; must copy to buffer in order to pad */
          /* with zeros safely; fortunately this is not the worst case */
          /* path because cannot have had a round */
-         uByte buffer[ROUNDUP(DECPMAX+3, 4)]; /* [+3 allows uInt padding] */
          uByte *s=umsd;                /* source */
          uByte *t=buffer;              /* safe target */
          uByte *tlsd=buffer+(ulsd-umsd)+shift; /* target LSD */
$

Reply via email to