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 tree-optimization/81814] Incorrect behaviour at -O0 (conditional operator)


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.

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