Bug#225186: g++-3.3: error compiling max value for a long long
Package: g++-3.3
Version: 1:3.3.2-4
Severity: normal
Tags: sid
-- System Information:
Debian Release: testing/unstable
Architecture: sparc
Kernel: Linux sun 2.4.18 #1 SMP Mon Jan 27 14:07:39 EST 2003 sparc64
Locale: LANG=en_US, LC_CTYPE=en_US
Versions of packages g++-3.3 depends on:
ii gcc-3.3 1:3.3.2-4 The GNU C compiler
ii gcc-3.3-base 1:3.3.2-4 The GNU Compiler Collection (base
ii libc6 2.3.2.ds1-10 GNU C Library: Shared libraries an
ii libstdc++5-3.3-dev 1:3.3.2-4 The GNU Standard C++ Library v3 (d
-- no debconf information
This gives an error on g++-3.3
and warnings on gcc-3.3 or g++ with -fpermissive.
I think the max value is correct because max + 1 --> negative max.
The program output:
jim@sun:/usr/local/645/sal$ ./type_test
max + 1 = -9223372036854775808
max - 1 = 9223372036854775806
max = 9223372036854775807, size = 8
The compiler messages:
jim@sun:/usr/local/645/sal$ g++ -o type_test type_test.c
type_test.c: In function nt main()':
type_test.c:7: error: integer constant is too large for "long" type
type_test.c:8: error: integer constant is too large for "long" type
type_test.c:9: error: integer constant is too large for "long" type
jim@sun:/usr/local/645/sal$ g++ -fpermissive -o type_test type_test.c
type_test.c: In function nt main()':
type_test.c:7: warning: integer constant is too large for "long" type
type_test.c:8: warning: integer constant is too large for "long" type
type_test.c:9: warning: integer constant is too large for "long" type
The code:
jim@sun:/usr/local/645/sal$ cat type_test.c
#include <stdio.h>
typedef long long sal_Int64;
sal_Int64 bit64;
#define SAL_MAX_INT64 ((sal_Int64) 0x7FFFFFFFFFFFFFFF)
int main(void)
{
bit64 = SAL_MAX_INT64 ;
printf("max + 1\t =\t%lld\n", SAL_MAX_INT64 + 1);
printf("max - 1\t =\t %lld\n", SAL_MAX_INT64 - 1);
printf("max\t =\t %lld, size = %d\n", bit64, sizeof(sal_Int64));
return(0);
}
Reply to: