bugGNU Octave - Bugs: bug #60169, error: call of overloaded pow is...

 
 

bug #60169: error: call of overloaded pow is ambiguous

Submitter:  Michele <michele31415>
Submitted:  Thu 04 Mar 2021 04:09:54 PM UTC
   
 
Category:  Configuration and Build System Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Build Failure
Status:  Fixed Assigned to:  None
Originator Name:  Michele Open/Closed:  * Closed
Release:  * 6.2.0 Operating System:  * Solaris/SunOS
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 10 Mar 2021 04:20:51 AM UTC, comment #8: 

I pushed the change on stable and merged with default:

http://hg.savannah.gnu.org/hgweb/octave/rev/24e62692e8ac

Closing as fixed.

John W. Eaton <jwe>
Group administrator
Tue 09 Mar 2021 04:15:51 PM UTC, comment #7: 

@jwe: It sounds like the patch worked in the end once it was applied.  Can you go ahead and push it to stable?

Rik <rik5>
Group administrator
Fri 05 Mar 2021 10:25:20 PM UTC, comment #6: 


comment #5:

> In the macro definition, all the lines must end in the backslash continuation character.


Oh.  I've never used this particular construct so I have no idea what I'm doing.  Adding the \'s fixed it and Table.cc now compiles cleanly.  Thanks.

Michele <michele31415>
Fri 05 Mar 2021 08:50:45 PM UTC, comment #5: 

In the macro definition, all the lines must end in the backslash continuation character.

John W. Eaton <jwe>
Group administrator
Fri 05 Mar 2021 07:27:59 PM UTC, comment #4: 

comment #3:

> If you want to copy something here and prevent savannah from attempting to format it, use verbatim tags (see the https://savannah.gnu.org/bugs/?group=octave&func=additem page) or attach a file.


Sorry about that.

> I have no idea why applying the patch failed for you.
>
> Can you apply it by hand?  The changes were quite simple.


Maybe I did it wrong:

libgui/graphics/Table.cc:84:5: error: 'type' does not name a type; did you mean 'wctype'?
     type ten = 10 ;
     ^~~~
     wctype
libgui/graphics/Table.cc:86:5: error: expected unqualified-id before 'if'
     if (format == 'n')                                                        \     ^~
libgui/graphics/Table.cc:97:5: error: expected unqualified-id before 'else'
     else if (format == 'F')                                                   \     ^~~~
libgui/graphics/Table.cc:105:5: error: expected unqualified-id before 'else'
     else if (format == 'E')                                                   \     ^~~~
libgui/graphics/Table.cc:117:5: error: expected unqualified-id before 'else'
     else                                                                      \     ^~~~
libgui/graphics/Table.cc: In function 'QString formatNumber(double, char, int)':libgui/graphics/Table.cc:83:3: error: a function-definition is not allowed here before '{' token
   {
   ^

And this is that part of the source:

#define FORMATNUMBER(type)                                                    \
  static QString formatNumber (type d,                                        \
                               char format = 'f',                             \
                               int precision = 4)                             \
  {
    type ten = 10 ;

    if (format == 'n')                                                        \
      {                                                                       \
        if (d == floor (d))                                                   \
          return QString::number (d, 'g', precision);                         \
 //       else if (d <= pow ((double)10, (double)precision - 1) && d > pow (10, 1 - precision))
          else if (d <= pow (ten, precision - 1)
                 && d > pow (ten, 1 - precision))
          return QString::number (d, 'f', precision);                         \
        else                                                                  \
          return QString::number (d, 'e', precision);                         \
      }                                                                       \
    else if (format == 'F')                                                   \
      {                                                                       \
        int exponent = floor (log10 (d) / 3) * 3;                             \
        d *= pow (ten, -exponent);                                             \
        return QString::number (d, 'f', precision) + "e" +                    \
          (exponent < 0 ? "-" : "+") +                                        \
          QString ("%1").arg (abs (exponent), 3, 10, QChar ('0'));            \
      }                                                                       \
    else if (format == 'E')                                                   \
      {                                                                       \
        int exponent = floor (log10 (d) / 3) * 3;                             \
      d *=  pow (ten, -exponent);
//        d *=  pow ((double)10, (double)-exponent);

        return QString::number (d,                                            \
                                'f',                                          \
                                precision - floor (log10 (d)) - 1) +          \
               "e" + (exponent < 0 ? "-" : "+") +                             \
               QString ("%1").arg (abs (exponent), 3, 10, QChar ('0'));       \
      }


Michele <michele31415>
Fri 05 Mar 2021 07:00:31 AM UTC, comment #3: 

If you want to copy something here and prevent savannah from attempting to format it, use verbatim tags (see the https://savannah.gnu.org/bugs/?group=octave&func=additem page) or attach a file.

I have no idea why applying the patch failed for you.

Can you apply it by hand?  The changes were quite simple.

John W. Eaton <jwe>
Group administrator
Fri 05 Mar 2021 12:46:55 AM UTC, comment #2: 

comment #1:

> Please try the attached patch.  If it solves the problem, I'll push the change.  Thanks.
>
> (file #50987)


I guess it partly worked.

bash-4.3$ gpatch -p1 < pow-diffs.txt
patching file libgui/graphics/Table.cc
Hunk #1 FAILED at 80.
Hunk #2 succeeded at 93 (offset 1 line).
Hunk #3 FAILED at 100.
2 out of 3 hunks FAILED -- saving rejects to file libgui/graphics/Table.cc.rej
bash-4.3$ more libgui/graphics/Table.cc.rej
--- libgui/graphics/Table.cc
+++ libgui/graphics/Table.cc
@@ -80,11 +80,13 @@
                                char format = 'f',                             \                                int precision = 4)                             \   {                                                                           \+    type ten = 10;                                                            \     if (format == 'n')                                                        \       {                                                                       \         if (d == floor (d))                                                   \           return QString::number (d, 'g', precision);                         \-        else if (d <= pow (10, precision - 1) && d > pow (10, 1 - precision)) \+        else if (d <= pow (ten, precision - 1)                                \+                 && d > pow (ten, 1 - precision))                             \           return QString::number (d, 'f', precision);                         \         else                                                                  \           return QString::number (d, 'e', precision);                         \@@ -100,7 +102,7 @@
     else if (format == 'E')                                                   \       {                                                                       \         int exponent = floor (log10 (d) / 3) 3;                             \-        d =  pow (10, -exponent);                                            \+        d *=  pow (ten, -exponent);                                           \         return QString::number (d,                                            \                                 'f',                                          \                                 precision - floor (log10 (d)) - 1) +          \bash-4.3$



Michele <michele31415>
Thu 04 Mar 2021 04:58:18 PM UTC, comment #1: 

Please try the attached patch.  If it solves the problem, I'll push the change.  Thanks.

(file #50987)

John W. Eaton <jwe>
Group administrator
Thu 04 Mar 2021 04:09:54 PM UTC, original submission:  

Building 6.2.0 on Solaris 10 SPARC, gmake stops with:

libgui/graphics/Table.cc:88:76: error: call of overloaded 'pow(int, int)' is ambiguous
         else if (d <= pow (10, precision - 1) && d > pow (10, 1 - precision)) \                                                                            ^
libgui/graphics/Table.cc:104:33: error: call of overloaded 'pow(int, int)' is ambiguous
         d *= pow (10, -exponent);
                                ^                                                                 

This is the same problem as in bug #54217: "Build fails with error: call of overloaded ‘pow(int, int)’ is ambiguous" from two years ago building 4.4.0, though in a different file.  Back then the suggested fix was

-      static const float tiny = pow (2, -50);
+      static const float tiny = octave::math::exp2 (-50.0f);

but it is not clear to me how to proceed in this case.

Michele <michele31415>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #50987:  pow-diffs.txt added by jwe (3KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by michele31415 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-03-10 jwe StatusPatch Reviewed Fixed
        Open/ClosedOpen Closed
    2021-03-09 rik5 StatusPatch Submitted Patch Reviewed
    2021-03-04 jwe Attached File- Added pow-diffs.txt, #50987
        StatusNone Patch Submitted

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code