Bug 27873 - [Patch] Fix compile error for ambigous call to abs()
Summary: [Patch] Fix compile error for ambigous call to abs()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other Other
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-31 03:54 PDT by Harald Fernengel
Modified: 2009-08-03 23:14 PDT (History)
1 user (show)

See Also:


Attachments
compile fix for ambigous call to abs() (1001 bytes, patch)
2009-07-31 03:54 PDT, Harald Fernengel
eric: review-
Details | Formatted Diff | Diff
same patch, but with updated ChangeLog entry (1.02 KB, patch)
2009-08-03 04:35 PDT, Harald Fernengel
abarth: commit-queue+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Fernengel 2009-07-31 03:54:33 PDT
Created attachment 33869 [details]
compile fix for ambigous call to abs()

DateMath.cpp calls abs(long int) - which is ambiguous in some tool chains, for example on QNX:

/home/harald/qt/qt/src/3rdparty/webkit/JavaScriptCore/wtf/DateMath.cpp: In function 'double WTF::parseDateFromNullTerminatedCharacters(const char*)':
/home/harald/qt/qt/src/3rdparty/webkit/JavaScriptCore/wtf/DateMath.cpp:844: error: call of overloaded 'abs(long int&)' is ambiguous
/opt/qnx640/target/qnx6///usr/include/stdlib.h:122: note: candidates are: int std::abs(int)
/opt/qnx640/target/qnx6///usr/include/math.h:1042: note:                 long double std::abs(long double)
/opt/qnx640/target/qnx6///usr/include/math.h:692: note:                 float std::abs(float)
/opt/qnx640/target/qnx6///usr/include/math.h:624: note:                 double std::abs(double)
make[1]: *** [obj/debug/DateMath.o] Error 1

Patch replaces the abs() call to labs(), which takes a long int and returns a long int. This also removes two implicit casts.
Comment 1 Darin Adler 2009-07-31 09:33:49 PDT
Comment on attachment 33869 [details]
compile fix for ambigous call to abs()

Another approach we use for issues like this is to put code in MathExtras.h to work around platform differences. Take a look at MathExtras.h to see what I mean.

But this change seems OK.

I think the change log is not so good. It says "fix compilation" which is far too vague. The bug mentions the QNX platform and the change log should too.

I'm going to say r=me, though, because this seems like a good fix.
Comment 2 Eric Seidel (no email) 2009-07-31 20:54:02 PDT
Comment on attachment 33869 [details]
compile fix for ambigous call to abs()

Please fix the ChangeLog per Darin's comments.
Comment 3 Harald Fernengel 2009-08-03 04:35:00 PDT
Created attachment 33970 [details]
same patch, but with updated ChangeLog entry

Updated ChangeLog entry as requested.
Comment 4 Adam Barth 2009-08-03 23:14:41 PDT
Comment on attachment 33970 [details]
same patch, but with updated ChangeLog entry

Clearing review flag on attachment: 33970

Sending        JavaScriptCore/ChangeLog
Sending        JavaScriptCore/wtf/DateMath.cpp
Transmitting file data ..
Committed revision 46746.
http://trac.webkit.org/changeset/46746
Comment 5 Adam Barth 2009-08-03 23:14:44 PDT
All reviewed patches have been landed.  Closing bug.