Bug #2461
closedINT64_MAX,INT64_MIN long long definition conflicts on x86_64 with firefox 17.0esr build
0%
Description
On current pkgsrc master, 3.3-DEVELOPMENT x86_64, building devel/xulrunner, associated with firefox 17.0esr, fails processing a C++ header file with an error message:
In file included from ../../dist/include/mozilla/FunctionTimer.h:11,
from /usr/pkgsrc/devel/xulrunner/work/mozilla-esr17/xpcom/glue/FileUtils.cpp:20:
../../dist/include/mozilla/TimeStamp.h: In static member function 'static mozilla::TimeDuration mozilla::TimeDuration::FromTicks(double)':
../../dist/include/mozilla/TimeStamp.h:137: error: call of overloaded 'FromTicks(long long int)' is ambiguous
../../dist/include/mozilla/TimeStamp.h:123: note: candidates are: static mozilla::TimeDuration mozilla::TimeDuration::FromTicks(int64_t)
../../dist/include/mozilla/TimeStamp.h:129: note: static mozilla::TimeDuration mozilla::TimeDuration::FromTicks(double)
gmake4: *** [FileUtils.o] Error 1
The relevant lines from the original TimeStamp.h located under devel/xulrunner/work/mozilla-esr17/xpcom/ds appear to be:
static TimeDuration FromTicks(int64_t aTicks) {
TimeDuration t;
t.mValue = aTicks;
return t;
}
static TimeDuration FromTicks(double aTicks) {
// NOTE: this MUST be a >= test, because int64_t(double(INT64_MAX))
// overflows and gives LL_MININT.
if (aTicks >= double(INT64_MAX))
return TimeDuration::FromTicks(INT64_MAX);
// This MUST be a <= test.
if (aTicks <= double(INT64_MIN))
return TimeDuration::FromTicks(INT64_MIN);
return TimeDuration::FromTicks(int64_t(aTicks));
}
// Duration in PRIntervalTime units
int64_t mValue;
A patch explictly casting in the above header file TimeStamp.h both INT64_MAX and INT64_MIN to int64_t allows building to at least proceed past the previous error.
Grepping for INT64_MAX and INT64_MIN under /usr/include reveals definitions:
#define INT64_MAX 0x7fffffffffffffffLL
#define INT64_MIN (-0x7fffffffffffffffLL-1)
The compiler being used is:
$ cc --version
cc (DragonFly) 4.4.7 2012.03.13
Files
Updated by davshao about 12 years ago
- File cppint64min.cpp cppint64min.cpp added
On DragonFly x86_64 for test file cppint64min.cpp
$ c++ -DUSECSTDINT -std=c++0x cppint64min.cpp
cppint64min.cpp: In function 'int main()':
cppint64min.cpp:22: error: call of overloaded 'printVal(long long int)' is ambiguous
cppint64min.cpp:10: note: candidates are: void TwoTypes::printVal(double)
cppint64min.cpp:14: note: void TwoTypes::printVal(int64_t)
whereas on NetBSD amd64 and Ubuntu 12.04 LTS
$ c++ -DUSECSTDINT -std=c++0x cppint64min.cpp
int64_t val = -9223372036854775808
(On Mac OS X Lion the same output occurs with command simply c++ cppint64min.cpp.)
#ifdef USECSTDINT
#include <cstdint>
#else
#include <stdint.h>
#endif
#include <iostream>
class TwoTypes {
public:
void printVal(double val) {
std::cout << "double val = " << val << "\n";
}
void printVal(int64_t val) {
std::cout << "int64_t val = " << val << "\n";
}
};
int main() {
TwoTypes t;
t.printVal(INT64_MIN);
return 0;
}
Updated by swildner about 12 years ago
- Status changed from New to Feedback
Thanks, I've pushed a fix. Please try and report back.
Updated by davshao about 12 years ago
In combination with
commit 38aa22ba71414a9ac96065bea03c600d63f289d5
Date: Thu Nov 29 00:26:41 2012 0100
<sys/errno.h>: Try to fix errno's declaration a bit better for C+.
- make quickworld && make buildkernel
on x86_64 now allows Firefox 17.0 esr to build and function correctly using pkgsrc current master. Thanks!