tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] Integer promotion issue?


From: Patrick Pelissier
Subject: [Tinycc-devel] Integer promotion issue?
Date: Sat, 31 Mar 2018 11:54:29 +0200

The following program:

#include <stdio.h>
#include <limits.h>
#include <stdint.h>

#define N_RESET(n, i)                                                  \
  (((n) & (~((ONE<< ABA_CPT)-1)) & ~(ONE << (LIMBSIZE - 1 - i)))       \
   |((aba_cpt_t)((n) + 1)))

#define LIMBSIZE (sizeof(limb_t) * CHAR_BIT)
#define ABA_CPT 32
#define ONE  ((limb_t)1)

typedef uint32_t aba_cpt_t;
typedef unsigned long long limb_t;

unsigned long long f(unsigned long long n, int i)
{
  return N_RESET(n, i);
}

int main()
{
  unsigned long long n = 9223372036854775809ULL;
  n = f(n, 0);
  printf ("N=%llu\n", n);
}

when compiled with TCC GIT c41caac02d53373b296ccb179b730ada62137cc0
produces the result on an linux/x86-64 platform:

N=9223372036854775810

whereas I was expecting

N=2

--
 Regards,
  Patrick PĂ©lissier



reply via email to

[Prev in Thread] Current Thread [Next in Thread]