Public bug reported:

I have an Ubuntu 14.04 system for arm7l (armhf), and I think
I have found a bug in the g++/gcc compiler.

I am expecting to see 'char c' below to end up as a negative number,
but as you can see, it does not.  x86 system shows the negative number
as expected.

Anyone have any ideas for a work-around, or proper code if mine is
buggy?


greearb@build-imx6:~/git/btbits/server$ more test.cc
#include <stdlib.h>
#include <stdio.h>

int main() {
   unsigned long long val = 0x8b;
   char c = val;
   printf("c: %d  0x%x\n", c, c);
   return 0;
}
greearb@build-imx6:~/git/btbits/server$ g++ -o test test.cc
greearb@build-imx6:~/git/btbits/server$ ./test
c: 139  0x8b
greearb@build-imx6:~/git/btbits/server$

greearb@build-imx6:~/git/btbits/server$ g++ --version
g++ (Ubuntu/Linaro 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


On x86 system:

[greearb@ben-dt ~]$ g++ -o test test.cc
[greearb@ben-dt ~]$ ./test
c: -117  0xffffff8b

[greearb@ben-dt ~]$ gcc --version
gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8)

** Affects: gcc-4.8 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to gcc-4.8 in Ubuntu.
https://bugs.launchpad.net/bugs/1446291

Title:
  gcc/g++ 4.8.2 won't convert uint64 to char properly.

Status in gcc-4.8 package in Ubuntu:
  New

Bug description:
  I have an Ubuntu 14.04 system for arm7l (armhf), and I think
  I have found a bug in the g++/gcc compiler.

  I am expecting to see 'char c' below to end up as a negative number,
  but as you can see, it does not.  x86 system shows the negative number
  as expected.

  Anyone have any ideas for a work-around, or proper code if mine is
  buggy?


  greearb@build-imx6:~/git/btbits/server$ more test.cc
  #include <stdlib.h>
  #include <stdio.h>

  int main() {
     unsigned long long val = 0x8b;
     char c = val;
     printf("c: %d  0x%x\n", c, c);
     return 0;
  }
  greearb@build-imx6:~/git/btbits/server$ g++ -o test test.cc
  greearb@build-imx6:~/git/btbits/server$ ./test
  c: 139  0x8b
  greearb@build-imx6:~/git/btbits/server$

  greearb@build-imx6:~/git/btbits/server$ g++ --version
  g++ (Ubuntu/Linaro 4.8.2-19ubuntu1) 4.8.2
  Copyright (C) 2013 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


  On x86 system:

  [greearb@ben-dt ~]$ g++ -o test test.cc
  [greearb@ben-dt ~]$ ./test
  c: -117  0xffffff8b

  [greearb@ben-dt ~]$ gcc --version
  gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.8/+bug/1446291/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to