Bug 53183 - MathExtras.h missing additional "using std::<cmathfunction>" statements
Summary: MathExtras.h missing additional "using std::<cmathfunction>" statements
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other Other
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-26 11:44 PST by Nick Landry
Modified: 2013-10-03 11:56 PDT (History)
11 users (show)

See Also:


Attachments
Patch adding additional "using std::<cmathfunction>" (3.07 KB, patch)
2011-01-26 11:59 PST, Nick Landry
darin: review-
darin: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Landry 2011-01-26 11:44:00 PST
Looking at the C++ spec, if cmath is included the only guarantee we have is that the math functions will appear in the std namespace (spec section 17.4.1.2 clause 4, http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf).  By only including cmath in MathExtras.h, we don't have any guarantees that the math functions will also appear in the global namespace.  MSVC headers include math functions in both std and in global, but RVCT 4 does not (without special compile parameters) and will fail to compile with missing identifiers.
Comment 1 Nick Landry 2011-01-26 11:59:17 PST
Created attachment 80214 [details]
Patch adding additional "using std::<cmathfunction>"

Since MathExtras.h was changed from math.h to use cmath, I've attached a patch which simply imports additional cmath functions into the global namespace.  I'm not sure if this is the best approach.
Comment 2 WebKit Review Bot 2011-01-26 12:02:27 PST
Attachment 80214 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1

Source/JavaScriptCore/wtf/MathExtras.h:215:  Use 'using namespace std;' instead of 'using std::acos;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:216:  Use 'using namespace std;' instead of 'using std::asin;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:217:  Use 'using namespace std;' instead of 'using std::atan2;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:218:  Use 'using namespace std;' instead of 'using std::atan2f;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:219:  Use 'using namespace std;' instead of 'using std::ceil;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:220:  Use 'using namespace std;' instead of 'using std::ceilf;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:221:  Use 'using namespace std;' instead of 'using std::cos;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:222:  Use 'using namespace std;' instead of 'using std::cosf;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:223:  Use 'using namespace std;' instead of 'using std::fabs;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:224:  Use 'using namespace std;' instead of 'using std::fabsf;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:225:  Use 'using namespace std;' instead of 'using std::floorf;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:226:  Use 'using namespace std;' instead of 'using std::fmod;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:227:  Use 'using namespace std;' instead of 'using std::hypot;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:228:  Use 'using namespace std;' instead of 'using std::sin;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:229:  Use 'using namespace std;' instead of 'using std::sinf;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:230:  Use 'using namespace std;' instead of 'using std::sqrt;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:231:  Use 'using namespace std;' instead of 'using std::sqrtf;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:232:  Use 'using namespace std;' instead of 'using std::tan;'.  [build/using_std] [4]
Source/JavaScriptCore/wtf/MathExtras.h:233:  Use 'using namespace std;' instead of 'using std::tanf;'.  [build/using_std] [4]
Total errors found: 19 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Nick Landry 2011-01-26 12:08:03 PST
I decided again having "using namespace std;" in a header file since I figured it could have unintended consequences for someone who includes it but may not want all of std imported.

(In reply to comment #2)
> Attachment 80214 [details] did not pass style-queue:
> 
> Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1
> 
> Source/JavaScriptCore/wtf/MathExtras.h:215:  Use 'using namespace std;' instead of 'using std::acos;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:216:  Use 'using namespace std;' instead of 'using std::asin;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:217:  Use 'using namespace std;' instead of 'using std::atan2;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:218:  Use 'using namespace std;' instead of 'using std::atan2f;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:219:  Use 'using namespace std;' instead of 'using std::ceil;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:220:  Use 'using namespace std;' instead of 'using std::ceilf;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:221:  Use 'using namespace std;' instead of 'using std::cos;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:222:  Use 'using namespace std;' instead of 'using std::cosf;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:223:  Use 'using namespace std;' instead of 'using std::fabs;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:224:  Use 'using namespace std;' instead of 'using std::fabsf;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:225:  Use 'using namespace std;' instead of 'using std::floorf;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:226:  Use 'using namespace std;' instead of 'using std::fmod;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:227:  Use 'using namespace std;' instead of 'using std::hypot;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:228:  Use 'using namespace std;' instead of 'using std::sin;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:229:  Use 'using namespace std;' instead of 'using std::sinf;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:230:  Use 'using namespace std;' instead of 'using std::sqrt;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:231:  Use 'using namespace std;' instead of 'using std::sqrtf;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:232:  Use 'using namespace std;' instead of 'using std::tan;'.  [build/using_std] [4]
> Source/JavaScriptCore/wtf/MathExtras.h:233:  Use 'using namespace std;' instead of 'using std::tanf;'.  [build/using_std] [4]
> Total errors found: 19 in 2 files
> 
> 
> If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Nick Landry 2011-01-26 12:09:28 PST
Should be "I decided against"

(In reply to comment #3)
> I decided again having "using namespace std;" in a header file since I figured it could have unintended consequences for someone who includes it but may not want all of std imported.
> 
> (In reply to comment #2)
> > Attachment 80214 [details] [details] did not pass style-queue:
> > 
> > Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1
> > 
> > Source/JavaScriptCore/wtf/MathExtras.h:215:  Use 'using namespace std;' instead of 'using std::acos;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:216:  Use 'using namespace std;' instead of 'using std::asin;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:217:  Use 'using namespace std;' instead of 'using std::atan2;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:218:  Use 'using namespace std;' instead of 'using std::atan2f;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:219:  Use 'using namespace std;' instead of 'using std::ceil;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:220:  Use 'using namespace std;' instead of 'using std::ceilf;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:221:  Use 'using namespace std;' instead of 'using std::cos;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:222:  Use 'using namespace std;' instead of 'using std::cosf;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:223:  Use 'using namespace std;' instead of 'using std::fabs;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:224:  Use 'using namespace std;' instead of 'using std::fabsf;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:225:  Use 'using namespace std;' instead of 'using std::floorf;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:226:  Use 'using namespace std;' instead of 'using std::fmod;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:227:  Use 'using namespace std;' instead of 'using std::hypot;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:228:  Use 'using namespace std;' instead of 'using std::sin;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:229:  Use 'using namespace std;' instead of 'using std::sinf;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:230:  Use 'using namespace std;' instead of 'using std::sqrt;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:231:  Use 'using namespace std;' instead of 'using std::sqrtf;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:232:  Use 'using namespace std;' instead of 'using std::tan;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:233:  Use 'using namespace std;' instead of 'using std::tanf;'.  [build/using_std] [4]
> > Total errors found: 19 in 2 files
> > 
> > 
> > If any of these errors are false positives, please file a bug against check-webkit-style.

(In reply to comment #3)
> I decided again having "using namespace std;" in a header file since I figured it could have unintended consequences for someone who includes it but may not want all of std imported.
> 
> (In reply to comment #2)
> > Attachment 80214 [details] [details] did not pass style-queue:
> > 
> > Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1
> > 
> > Source/JavaScriptCore/wtf/MathExtras.h:215:  Use 'using namespace std;' instead of 'using std::acos;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:216:  Use 'using namespace std;' instead of 'using std::asin;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:217:  Use 'using namespace std;' instead of 'using std::atan2;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:218:  Use 'using namespace std;' instead of 'using std::atan2f;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:219:  Use 'using namespace std;' instead of 'using std::ceil;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:220:  Use 'using namespace std;' instead of 'using std::ceilf;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:221:  Use 'using namespace std;' instead of 'using std::cos;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:222:  Use 'using namespace std;' instead of 'using std::cosf;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:223:  Use 'using namespace std;' instead of 'using std::fabs;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:224:  Use 'using namespace std;' instead of 'using std::fabsf;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:225:  Use 'using namespace std;' instead of 'using std::floorf;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:226:  Use 'using namespace std;' instead of 'using std::fmod;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:227:  Use 'using namespace std;' instead of 'using std::hypot;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:228:  Use 'using namespace std;' instead of 'using std::sin;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:229:  Use 'using namespace std;' instead of 'using std::sinf;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:230:  Use 'using namespace std;' instead of 'using std::sqrt;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:231:  Use 'using namespace std;' instead of 'using std::sqrtf;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:232:  Use 'using namespace std;' instead of 'using std::tan;'.  [build/using_std] [4]
> > Source/JavaScriptCore/wtf/MathExtras.h:233:  Use 'using namespace std;' instead of 'using std::tanf;'.  [build/using_std] [4]
> > Total errors found: 19 in 2 files
> > 
> > 
> > If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 WebKit Review Bot 2011-01-26 12:15:09 PST
Attachment 80214 [details] did not build on chromium:
Build output: http://queues.webkit.org/results/7578364
Comment 6 Build Bot 2011-01-26 12:35:15 PST
Attachment 80214 [details] did not build on win:
Build output: http://queues.webkit.org/results/7531341
Comment 7 Early Warning System Bot 2011-01-26 12:37:02 PST
Attachment 80214 [details] did not build on qt:
Build output: http://queues.webkit.org/results/7627333
Comment 8 WebKit Review Bot 2011-01-26 12:46:14 PST
Attachment 80214 [details] did not build on gtk:
Build output: http://queues.webkit.org/results/7528338
Comment 9 Darin Adler 2011-01-26 12:57:28 PST
Comment on attachment 80214 [details]
Patch adding additional "using std::<cmathfunction>"

View in context: https://bugs.webkit.org/attachment.cgi?id=80214&action=review

review- because this is breaking the build on every platform!

>> Source/JavaScriptCore/wtf/MathExtras.h:215
>> +using std::acos;
> 
> Use 'using namespace std;' instead of 'using std::acos;'.  [build/using_std] [4]

The stylebot should enforce that rule in .cpp files, but not in .h files.
Comment 10 Nick Landry 2011-01-28 10:21:28 PST
Looks like most platforms don't put the C99 math functions into the std namespace like RVCT does.  I can post another patch that moves all the C99 math function using statements into a RVCT specific if/def block.  It isn't pretty though.  Are there any other alternatives?

Could we go back to just including <math.h> instead of <cmath>?



(In reply to comment #9)
> (From update of attachment 80214 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=80214&action=review
> 
> review- because this is breaking the build on every platform!
>
Comment 11 Daniel Bates 2011-01-28 11:57:25 PST
CC'ing Laszlo Gombos, Siddharth Mathur, Jocelyn Turcotte for any insight/suggestions with regards to this issue <https://bugs.webkit.org/show_bug.cgi?id=53183#c10>.
Comment 12 Laszlo Gombos 2011-01-31 09:21:27 PST
Symbian - building with RVCT - does not have this build problem as the Symbian tool chain preincludes a file called "rvct.h" which makes math functions appear in the global namespace (the file is available e.g. in the SDK - http://labs.qt.nokia.com/2011/01/20/qt-sdk-1-1-technology-preview-released/).

In case we decide to import functions into the global namespace with "using std::XX" it needs to be guarded with at least !COMPILER(WINSCW) && !(COMPILER(RVCT) && OS(SYMBIAN)). 

I do not have a strong preference on including cmath vs. math.h.
Comment 13 Laszlo Gombos 2012-08-05 14:27:40 PDT
Nick, do you still have an interest to resolve this ? Are you using RVCT ?
Comment 14 Laszlo Gombos 2012-08-05 14:31:57 PDT
(In reply to comment #13)
> Nick, do you still have an interest to resolve this ? Are you using RVCT ?

Perhaps this was resolved by http://trac.webkit.org/changeset/101041. Can this bug be closed ?
Comment 15 Alexey Proskuryakov 2013-10-03 11:56:24 PDT
No response in over a year, marking resolved.