This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/65752] Too strong optimizations int -> pointer casts
- From: "ch3root at openwall dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 15 Nov 2015 21:53:41 +0000
- Subject: [Bug tree-optimization/65752] Too strong optimizations int -> pointer casts
- Auto-submitted: auto-generated
- References: <bug-65752-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65752
--- Comment #42 from Alexander Cherepanov <ch3root at openwall dot com> ---
On 2015-11-16 00:48, pinskia at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65752
>
> --- Comment #41 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
> (In reply to Alexander Cherepanov from comment #40)
>> Ok, this program:
>>
>> #include <stdint.h>
>> #include <stdio.h>
>>
>> int main() {
>> int y, x = 0;
>> int *volatile v = &x;
>> int *xp = v;
>> int *i = &y + 1;
>>
>> if (xp != i) {
>> printf("hello\n");
>> xp = i;
>> }
>>
>> printf("%d\n", xp == &x);
>> }
Small correction: it prints 0 and doesn't print "hello" even though it
should print 1 without "hello" or an unspecified value with "hello".
> Still undefined as &x and &y + 1 are not comparable.
They cannot be compared with the relational operators ("<" etc.) but you
can compare any pointers with the equality operators ("==" and "!=").