This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/13208] Wrong expression evaluation when using data type or cast "long long"


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]