LLONG_MIN and LLONG_MAX constants in C++ code

Hello!

There’s a bug in /usr/include/limits.h file in 6.2.
If compiled with C code, LLONG_xxx constants are OK (endind with LL),
but with C++ compilation fails:

[compiler output]
22.cc: In function `int main()’:
22.cc:6: integer constant out of range
22.cc:6: warning: decimal integer constant is so large that it is unsigned

[limits.h file]

#if INT_BITS-0 == 64
#define LLONG_MIN (-9223372036854775807LL-1) /* minimum value of a
long long /
#define LLONG_MAX 9223372036854775807LL /
maximum value of a
long long /
#define ULLONG_MAX 18446744073709551615ULL /
maximum value of an
unsigned long long /
#else
#define LLONG_MIN (-9223372036854775807-1) /
minimum value of a
long long /
#define LLONG_MAX 9223372036854775807 /
maximum value of a
long long /
#define ULLONG_MAX 18446744073709551615U /
maximum value of an
unsigned long long */
#endif

Dmitry Alexeyev

Thanks Dmitry. This has been fixed. The LL and ULL modifiers are
on the wrong set of defines.

Dmitry Alexeyev <dmi@qnx.org.ru> wrote:

Hello!

There’s a bug in /usr/include/limits.h file in 6.2.
If compiled with C code, LLONG_xxx constants are OK (endind with LL),
but with C++ compilation fails:

[compiler output]
22.cc: In function `int main()’:
22.cc:6: integer constant out of range
22.cc:6: warning: decimal integer constant is so large that it is unsigned

[limits.h file]

#if INT_BITS-0 == 64
#define LLONG_MIN (-9223372036854775807LL-1) /* minimum value of a
long long /
#define LLONG_MAX 9223372036854775807LL /
maximum value of a
long long /
#define ULLONG_MAX 18446744073709551615ULL /
maximum value of an
unsigned long long /
#else
#define LLONG_MIN (-9223372036854775807-1) /
minimum value of a
long long /
#define LLONG_MAX 9223372036854775807 /
maximum value of a
long long /
#define ULLONG_MAX 18446744073709551615U /
maximum value of an
unsigned long long */
#endif

Dmitry Alexeyev


cburgess@qnx.com

Colin Burgess ÐÉÛÅÔ:

Thanks Dmitry. This has been fixed. The LL and ULL modifiers are
on the wrong set of defines.

But why it works in two different ways on one machine with C and C++
compilers? C compiler gets into first set, and C++ into second one.

Dmitry

It doesn’t get the two different cases, but the default type of
constants is different between the C and C++ compilers.

Thanks Dmitry. This has been fixed. The LL and ULL modifiers are
on the wrong set of defines.

But why it works in two different ways on one machine with C and C++
compilers? C compiler gets into first set, and C++ into second one.

Dmitry


cburgess@qnx.com