This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/81814] Incorrect behaviour at -O0 (conditional operator)
- From: "d25fe0be at outlook dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 11 Aug 2017 13:22:33 +0000
- Subject: [Bug tree-optimization/81814] Incorrect behaviour at -O0 (conditional operator)
- Auto-submitted: auto-generated
- References: <bug-81814-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81814
--- Comment #4 from d25fe0be@ <d25fe0be at outlook dot com> ---
Per n4659 7.8/[conv.integral]:
```
If the destination type is signed, the value is unchanged if it can be
represented in the destination type;
otherwise, the value is implementation-defined.
```
Isn't `(char)xxx` implementation-defined? (as GCC treats `char` as signed)
And as the following code prints 0, I believe that GCC defines the result of
such casting as 0:
```
#include <stdio.h>
int xxx = 0x01000000;
int main() {
printf("%d\n", (char)xxx);
return 0;
}
```
So I think the output should indeed be 0.