This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/13208] Wrong expression evaluation when using data type or cast "long long"
- From: "RDruegh at t-online dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Nov 2003 23:21:36 -0000
- Subject: [Bug c/13208] Wrong expression evaluation when using data type or cast "long long"
- References: <20031126223709.13208.druegh@informatik.tu-muenchen.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From RDruegh at t-online dot de 2003-11-26 23:21 -------
Subject: Re: Wrong expression evaluation when using data type
or cast "long long"
Hello,
pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org 2003-11-26 22:43 -------
> signed is always promoted to unsigned when multipling, sorry learn some c.
>
I don't want to waste your time, but it would be kind of you to have
another look at the problem or to be more detailed about why this is no
bug. And I'm sorry since I forgot about to append the output.
If you add the following to my programm, the calculation result is
correct so I think it is related to "long long":
{
int c; char v=-1; unsigned short w=6;
c = v*w; printf("c=%i, (short)c=%hi\n",c,(short)c);
}
Same pattern, but correct result.
What is also provided in the example is that the casts (signed) and
(long long) (which should be expanded to "signed long long" by the
compiler, if I'm not completely wrong) behave differently.
--- Complete Output after adding lines above -------------------------
b=4294967290, (int)b=-6
b=4294967290, (int)b=-6
b=-6, (int)b=-6
b=-6, (int)b=-6
b=4294967290, (int)b=-6
b=-6, (int)b=-6
b=-6, (int)b=-6
c=-6, (short)c=-6
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13208