[cfe-dev] MS 128-bit literals don't always have the correct type
Kim Gräsman
kim.grasman at gmail.com
Mon Sep 24 11:09:33 PDT 2012
(+cfe-dev)
---------- Forwarded message ----------
From: Kim Gräsman <kim.grasman at gmail.com>
Date: Mon, Sep 24, 2012 at 7:18 AM
Subject: Re: [cfe-dev] MS 128-bit literals don't always have the correct type
To: Richard Smith <richard at metafoo.co.uk>
Hi Richard,
On Mon, Sep 24, 2012 at 6:46 AM, Richard Smith <richard at metafoo.co.uk> wrote:
> Incidentally, we currently treat (for instance) 1000000000000000000i32 as a
> 64-bit integer. How does MSVC behave here? (Does i32 mean "this shall be an
> int32_t", or does it mean "this shall be *at least* an int32_t"?)
This:
#include <iostream>
#include <typeinfo>
int main(int argc, char* argv[])
{
auto i = 1000000000000000000i32;
std::cout << typeid(i).name() << ": " << i << std::endl;
return 0;
}
prints
int: -1486618624
So it looks like MSVC honors the literal suffix, no matter if the
value fits or not. Removing the i32 suffix makes it an __int64 of the
given value.
This is on VC++10, SP1.
- Kim
More information about the cfe-dev
mailing list