Hacker News new | past | comments | ask | show | jobs | submit login

> UB is clearly undesirable, but assuming it is impossible and deducing other outcomes must be meant are clearly wrong assumptions by the compiler writer.

Compilers can and absolutely do assume that UB is impossible in this code (no integer overflow) and deduce other outcomes must be meant (the loop operates on contiguous memory):

  void foo(char* arr, int32_t end)
  {
    for (int32_t i = 0; i != end; ++i)
      arr[i] = 0;
  }
(Based on code from the gist comments.)



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: