This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: GCC has problems with 64-bit multiplication
- From: Graham Stott <graham dot stott at btinternet dot com>
- To: Hans Petter Selasky <hselasky at c2i dot net>, gcc-bugs at gcc dot gnu dot org
- Date: Thu, 8 Feb 2007 15:02:35 +0000 (GMT)
- Subject: Re: GCC has problems with 64-bit multiplication
All,
Not a bug in GCC the result is correct as you've only asked for a 32-bit
multiply.
--- Hans Petter Selasky <hselasky@c2i.net> wrote:
> Test program:
>
> #include <stdio.h>
> #include <sys/types.h>
>
> int main() {
>
> int32_t a = 0x40000000;
> int16_t b = 0x4000;
> int64_t c = a * b;
^^^^^ this is a 32-bit multiply with the result widened
to 64-bit,
> printf("0x%016llx\n", c);
>
> return 0;
> }
>