This is the mail archive of the gcc@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]

Why GCC 4.1.2 casting "short int" to "short unsigned int" ?


GCC4.1.2 on a Intel Xeon CPU
The test program is test.c:

extern int bar(short);

int foo(short arg1, short arg2)
{
  short res;
  res = arg1 + arg2;
  return bar(res);
}

Compiled with : gcc -fdump-tree-all -S test.c
The resulting test.c.t02.original is :
;; Function foo (foo)
;; enabled by -tree-original

{
  short int res;

    short int res;
  res = (short int) ((short unsigned int) arg1 + (short unsigned int) arg2);
  return bar ((int) res);
}

So, my question is : why gcc casted "short" to "short unsigned int"
before addition and casted back after?
--
                                       此致
敬礼!

                                    梁?


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