LINUX.ORG.RU

История изменений

Исправление fsb4000, (текущая версия) :

Кстати, мне немного стыдно, но я не понимаю, почему при сборке gcc результат false.

Потому что в стандарте так написано.

6.5.9 Equality operators, пункт 7

Two pointers compare equal if and only if both are null pointers, both are pointers to the same object (including a pointer to an object and a subobject at its beginning) or function, both are pointers to one past the last element of the same array object, or one is a pointer to one past the end of one array object and the other is a pointer to the start of a different array object that happens to immediately follow the first array object in the address space

Здесь видно что это адреса указывают на разные объекты, так что оптимизатор сразу заменяет на false, не сравнивая значения указателей.

Исправление fsb4000, :

Кстати, мне немного стыдно, но я не понимаю, почему при сборке gcc результат false.

Потому что в стандарте так написано.

6.5.9 Equality operators, пункт 7

Two pointers compare equal if and only if both are null pointers, both are pointers to the same object (including a pointer to an object and a subobject at its beginning) or function, both are pointers to one past the last element of the same array object, or one is a pointer to one past the end of one array object and the other is a pointer to the start of a different array object that happens to immediately follow the first array object in the address space

Здесь видно что это адреса указывающие на разные объекты, так что оптимизатор сразу заменяет на false, не сравнивая значения указателей.

Исходная версия fsb4000, :

Кстати, мне немного стыдно, но я не понимаю, почему при сборке gcc результат false.

Потому что в стандарте так написано.

6.5.9 Equality operators, пункт 7

Two pointers compare equal if and only if both are null pointers, both are pointers to the same object (including a pointer to an object and a subobject at its beginning) or function, both are pointers to one past the last element of the same array object, or one is a pointer to one past the end of one array object and the other is a pointer to the start of a different array object that happens to immediately follow the first array object in the address space