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/65752] Too strong optimizations int -> pointer casts


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 "!=").

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