[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#629137: gcc-4.6: on amd64, sizeof(__int128_t) > sizeof(intmax_t)



Package: gcc-4.6
Version: 4.6.0-10
Severity: normal

ISO C draft n1124[0] specifies (§7.18.1.5):

  The following type designates a signed integer type capable of
  representing any value of any signed integer type:
  
  intmax_t
  
  The following type designates an unsigned integer type capable of
  representing any value of any unsigned integer type:
  
  uintmax_t
  
  These types are required.

However, on amd64, which supports 128-bit integers, intmax_t is defined
as a "long int", which is not capable of representing some values of the
signed integer type __int128_t.  I presume this is also the case with
the corresponding unsigned types.  A testcase is attached which confirms
this when run with "gcc -std=c99 testcase.c".  A preprocessed version is
also attached.

Please be aware that this will also affect the preprocessor, since it
must evaluate constants as if they used intmax_t and uintmax_t.

[0] I used this because I don't really want to purchase the actual C99
standard.  Feel free to confirm this with someone who actually owns a
copy of the document.

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.39-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages gcc-4.6 depends on:
ii  binutils              2.21.51.20110523-1 The GNU assembler, linker and bina
ii  cpp-4.6               4.6.0-10           The GNU C preprocessor
ii  gcc-4.6-base          4.6.0-10           The GNU Compiler Collection (base 
ii  libc6                 2.13-4             Embedded GNU C Library: Shared lib
ii  libcloog-ppl0         0.15.9-3           the Chunky Loop Generator (runtime
ii  libgcc1               1:4.6.0-10         GCC support library
ii  libgmp10              2:5.0.1+dfsg-7     Multiprecision arithmetic library
ii  libgmpxx4ldbl         2:5.0.1+dfsg-7     Multiprecision arithmetic library 
ii  libgomp1              4.6.0-10           GCC OpenMP (GOMP) support library
ii  libmpc2               0.9-3              multiple precision complex floatin
ii  libmpfr4              3.0.1-3            multiple precision floating-point 
ii  libppl-c4             0.11.2-3           Parma Polyhedra Library (C interfa
ii  libppl9               0.11.2-3           Parma Polyhedra Library (runtime l
ii  libquadmath0          4.6.0-10           GCC Quad-Precision Math Library
ii  zlib1g                1:1.2.3.4.dfsg-3   compression library - runtime

Versions of packages gcc-4.6 recommends:
ii  libc6-dev                     2.13-4     Embedded GNU C Library: Developmen

Versions of packages gcc-4.6 suggests:
pn  binutils-gold                 <none>     (no description available)
pn  gcc-4.6-doc                   <none>     (no description available)
pn  gcc-4.6-locales               <none>     (no description available)
ii  gcc-4.6-multilib              4.6.0-10   The GNU C compiler (multilib files
pn  libgcc1-dbg                   <none>     (no description available)
pn  libgomp1-dbg                  <none>     (no description available)
pn  libmudflap0-4.6-dev           <none>     (no description available)
pn  libmudflap0-dbg               <none>     (no description available)
pn  libquadmath0-dbg              <none>     (no description available)

-- no debconf information

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
#include <stdint.h>

void abort(void);

int main(void)
{
	intmax_t maxnum;
	__int128_t bignum = 1;

	bignum <<= 69;

	maxnum = bignum;

	if (maxnum != bignum)
		abort();

	return 0;
}
# 1 "testcase.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "testcase.c"
# 1 "/usr/lib/gcc/x86_64-linux-gnu/4.6.1/include/stdint.h" 1 3 4


# 1 "/usr/include/stdint.h" 1 3 4
# 26 "/usr/include/stdint.h" 3 4
# 1 "/usr/include/features.h" 1 3 4
# 323 "/usr/include/features.h" 3 4
# 1 "/usr/include/bits/predefs.h" 1 3 4
# 324 "/usr/include/features.h" 2 3 4
# 356 "/usr/include/features.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 353 "/usr/include/sys/cdefs.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 354 "/usr/include/sys/cdefs.h" 2 3 4
# 357 "/usr/include/features.h" 2 3 4
# 388 "/usr/include/features.h" 3 4
# 1 "/usr/include/gnu/stubs.h" 1 3 4



# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 5 "/usr/include/gnu/stubs.h" 2 3 4




# 1 "/usr/include/gnu/stubs-64.h" 1 3 4
# 10 "/usr/include/gnu/stubs.h" 2 3 4
# 389 "/usr/include/features.h" 2 3 4
# 27 "/usr/include/stdint.h" 2 3 4
# 1 "/usr/include/bits/wchar.h" 1 3 4
# 28 "/usr/include/stdint.h" 2 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 29 "/usr/include/stdint.h" 2 3 4
# 37 "/usr/include/stdint.h" 3 4
typedef signed char int8_t;
typedef short int int16_t;
typedef int int32_t;

typedef long int int64_t;







typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;

typedef unsigned int uint32_t;



typedef unsigned long int uint64_t;
# 66 "/usr/include/stdint.h" 3 4
typedef signed char int_least8_t;
typedef short int int_least16_t;
typedef int int_least32_t;

typedef long int int_least64_t;






typedef unsigned char uint_least8_t;
typedef unsigned short int uint_least16_t;
typedef unsigned int uint_least32_t;

typedef unsigned long int uint_least64_t;
# 91 "/usr/include/stdint.h" 3 4
typedef signed char int_fast8_t;

typedef long int int_fast16_t;
typedef long int int_fast32_t;
typedef long int int_fast64_t;
# 104 "/usr/include/stdint.h" 3 4
typedef unsigned char uint_fast8_t;

typedef unsigned long int uint_fast16_t;
typedef unsigned long int uint_fast32_t;
typedef unsigned long int uint_fast64_t;
# 120 "/usr/include/stdint.h" 3 4
typedef long int intptr_t;


typedef unsigned long int uintptr_t;
# 135 "/usr/include/stdint.h" 3 4
typedef long int intmax_t;
typedef unsigned long int uintmax_t;
# 4 "/usr/lib/gcc/x86_64-linux-gnu/4.6.1/include/stdint.h" 2 3 4
# 2 "testcase.c" 2

void abort(void);

int main(void)
{
 intmax_t maxnum;
 __int128_t bignum = 1;

 bignum <<= 69;

 maxnum = bignum;

 if (maxnum != bignum)
  abort();

 return 0;
}

Attachment: signature.asc
Description: Digital signature


Reply to: