Closed Bug 818391 Opened 12 years ago Closed 12 years ago

nsMultiplexInputStream.cpp(514) : error C2668: 'abs' : ambiguous call to overloaded function

Categories

(Core :: General, defect)

x86
Windows 7
defect
Not set
blocker

Tracking

()

RESOLVED FIXED
mozilla20

People

(Reporter: philip.chee, Assigned: longsonr)

References

Details

Attachments

(1 file, 1 obsolete file)

MVS2008SP1 on Windows7 x64: c:/t1/hg/comm-central/mozilla/xpcom/io/nsMultiplexInputStream.cpp(514) : error C2668: 'abs' : ambiguous call to overloaded function C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\math.h(485): could be 'long abs(long)' C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\math.h(487): or 'doubleabs(double)' C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\math.h(491): or 'float abs(float)' C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\math.h(539): or 'long double abs(long double)' C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\stdlib.h(380): or 'int abs(int)' while trying to match the argument list '(int64_t)' c:/t1/hg/comm-central/mozilla/xpcom/io/nsMultiplexInputStream.cpp(522) : error C2668: 'abs' : ambiguous call to overloaded function C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\math.h(485): could be 'long abs(long)' C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\math.h(487): or 'doubleabs(double)' C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\math.h(491): or 'float abs(float)' C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\math.h(539): or 'long double abs(long double)' C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\stdlib.h(380): or 'int abs(int)' while trying to match the argument list '(int64_t)'
Sorry I broke your build. I'm a bit puzzled why it doesn't pick abs(long) though - is 'long' not 64-bit? If you add back the NS_ABS template in this file and revert the change, does the build succeed?
C++11 is required to have std::abs(long long) but apparently MVS2008SP1 doesn't. Perhaps we could add it to std namespace with something like: #if VISUAL_VERSION <= 2008 // or whatever namespace std { long long abs(long long v) { return llabs(v); } } #endif
(In reply to Mats Palmgren [:mats] from comment #1) > Sorry I broke your build. I'm a bit puzzled why it doesn't pick abs(long) > though - > is 'long' not 64-bit? If you add back the NS_ABS template in this file and > revert the change, does the build succeed? With MS Visual Studio long is 32 bit (same as int) 64 bit would be long long.
I see, thanks. Does the suggested std::abs(long long) overload work if you put it in nsMultiplexInputStream.cpp?
Attached patch patch (obsolete) — Splinter Review
This works. My compilation is still running so I don't know if it's the only place yet.
Thanks for investigating. I think I still prefer the "long long" type though (if it works), so we use the exact same signatures for all platforms. Perhaps it's better to add it to nsAlgorithm.h even if it turns out to be just this file, so that it will work for new code. (I didn't remove any of the #includes for nsAlgorithm.h in bug 817574)
Comment on attachment 688778 [details] [diff] [review] patch All the other files compile OK.
Attachment #688778 - Flags: review?(matspal)
Attached patch or this...Splinter Review
Assignee: nobody → longsonr
Attachment #688778 - Attachment is obsolete: true
Attachment #688778 - Flags: review?(matspal)
Attachment #688831 - Flags: review?(matspal)
Comment on attachment 688831 [details] [diff] [review] or this... Looks good to me, but I'm not a xpcom peer.
Attachment #688831 - Flags: review?(matspal)
Attachment #688831 - Flags: review?(justin.lebar+bug)
Attachment #688831 - Flags: review+
Attachment #688831 - Flags: review?(justin.lebar+bug) → review+
Severity: normal → blocker
Depends on: 818809
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla20
Blocks: 925129
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: