Bug 32675 - HTMLInputElement::stepMismatch() uses ambiguous overload of pow()
Summary: HTMLInputElement::stepMismatch() uses ambiguous overload of pow()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Steve Block
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-17 11:34 PST by Steve Block
Modified: 2009-12-17 23:45 PST (History)
7 users (show)

See Also:


Attachments
Patch 1 for Bug 32675 (1.71 KB, patch)
2009-12-17 11:46 PST, Steve Block
no flags Details | Formatted Diff | Diff
constant fix as recommended by Darin (1.59 KB, patch)
2009-12-17 23:01 PST, Eric Seidel (no email)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Block 2009-12-17 11:34:19 PST
HTMLInputElement::stepMismatch() calls pow() with two integer arguments. This causes a compile error due to an ambiguous overload on Android.

This was added in http://trac.webkit.org/changeset/51159
Comment 1 Steve Block 2009-12-17 11:46:57 PST
Created attachment 45099 [details]
Patch 1 for Bug 32675

Cast first argument of pow to double to force 'double pow(double, int)'
Comment 2 WebKit Review Bot 2009-12-17 11:49:48 PST
style-queue ran check-webkit-style on attachment 45099 [details] without any errors.
Comment 3 Eric Seidel (no email) 2009-12-17 12:49:48 PST
Comment on attachment 45099 [details]
Patch 1 for Bug 32675

This looks OK to me.  It would be nice if you could post the error in the bug for posterity, or even in the ChangeLog.  It's not clear to me what other signature on Andriod would be causing this error.
Comment 4 Eric Seidel (no email) 2009-12-17 12:51:03 PST
(I CC'd darin adler just because he was one of the primary driving forces behind our MathExtras.h and similar WTF files which deal with x-platform issues similar to this one.  I figured he might like to see this go by.)
Comment 5 Steve Block 2009-12-17 14:19:03 PST
The build error is ...

external/webkit/WebCore/html/HTMLInputElement.cpp:343: error: call of overloaded 'pow(int, int)' is ambiguous
bionic/libm/include/math.h:222: note: candidates are: double pow(double, double)
external/webkit/WebKit/android/stlport/stl/_cmath.h:443: note:                 float pow(float, float)
external/webkit/WebKit/android/stlport/stl/_cmath.h:443: note:                 long double pow(long double, long double)
external/webkit/WebKit/android/stlport/stl/_cmath.h:448: note:                 float pow(float, int)
external/webkit/WebKit/android/stlport/stl/_cmath.h:455: note:                 double pow(double, int)
external/webkit/WebKit/android/stlport/stl/_cmath.h:468: note:                 long double pow(long double, int)

The problem is that pow(int, int) isn't defined, nor is it in the c standard or c98.
Comment 6 Eric Seidel (no email) 2009-12-17 14:26:43 PST
We have a pow() in MathExtras:
http://trac.webkit.org/browser/trunk/JavaScriptCore/wtf/MathExtras.h

We also seem to try hard to avoid use of cmath:
http://trac.webkit.org/changeset/13104
http://trac.webkit.org/changeset/11667
http://trac.webkit.org/changeset/12225

And sometimes add it?
http://trac.webkit.org/changeset/10511

I'm not convinced this is the right work-around.  It would be nice if someone who is more familiar with our historical header troubles could comment.
Comment 7 Eric Seidel (no email) 2009-12-17 14:28:12 PST
Actually, I take that back.  This change has nothing really to do with cmath.  I think it's still fine.
Comment 8 WebKit Commit Bot 2009-12-17 14:37:26 PST
Comment on attachment 45099 [details]
Patch 1 for Bug 32675

Clearing flags on attachment: 45099

Committed r52292: <http://trac.webkit.org/changeset/52292>
Comment 9 WebKit Commit Bot 2009-12-17 14:37:31 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Darin Adler 2009-12-17 16:48:12 PST
I would have preferred the use of the constant, 2.0, which is a double rather than writing it as static_cast<double>(2), which seems less elegant to me.
Comment 11 Eric Seidel (no email) 2009-12-17 16:58:45 PST
Bah!  Agreed.  Clearly i wans't thinking.  I'll fix it.
Comment 12 Eric Seidel (no email) 2009-12-17 23:01:43 PST
Created attachment 45126 [details]
constant fix as recommended by Darin
Comment 13 Eric Seidel (no email) 2009-12-17 23:08:12 PST
Going to have the commit-queue land this for me to make sure I didn't make any stupid typos.  This laptop is too slow to build on.
Comment 14 Eric Seidel (no email) 2009-12-17 23:08:52 PST
Comment on attachment 45126 [details]
constant fix as recommended by Darin

Make the commit-queue land this.  Since I already filled in the reviewer the commit-queue won't get confused by me marking this r+.
Comment 15 mitz 2009-12-17 23:16:31 PST
And since it’s C++, you could also use numeric_limits<double>::digits() instead of DBL_MANT_DIG
Comment 16 WebKit Commit Bot 2009-12-17 23:17:20 PST
Comment on attachment 45126 [details]
constant fix as recommended by Darin

Clearing flags on attachment: 45126

Committed r52302: <http://trac.webkit.org/changeset/52302>
Comment 17 WebKit Commit Bot 2009-12-17 23:17:26 PST
All reviewed patches have been landed.  Closing bug.
Comment 18 Eric Seidel (no email) 2009-12-17 23:45:36 PST
Nifty.  I don't actually know what either of those values do. :)  But that's OK.  That part of this function wasn't touched by either patch.  I'm not going to go back and do the limits conversion now, but if I'm ever in that code again I'd be happy to!