[all-commits] [llvm/llvm-project] 50c444: [libc] fix behavior of strrchr(x, '\0') (#112620)

George Burgess IV via All-commits all-commits at lists.llvm.org
Wed Oct 30 15:08:24 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 50c44478fe3f680374edf1363d2a3617b8ff2a0b
      https://github.com/llvm/llvm-project/commit/50c44478fe3f680374edf1363d2a3617b8ff2a0b
  Author: George Burgess IV <george.burgess.iv at gmail.com>
  Date:   2024-10-30 (Wed, 30 Oct 2024)

  Changed paths:
    M libc/src/string/string_utils.h
    M libc/test/UnitTest/LibcTest.h
    M libc/test/src/string/StrchrTest.h

  Log Message:
  -----------
  [libc] fix behavior of strrchr(x, '\0') (#112620)

`strrchr("foo", '\0')` is defined to point to the end of `foo`, rather
than returning NULL. This wasn't caught by tests, since llvm-libc's
`ASSERT_STREQ(nullptr, "");` is not an assertion error.

While I'm here, refactor the test slightly to check for NULL more
specifically. I considered adding fancier `ASSERT`s (and changing the
semantics of `ASSERT_STREQ`), but opted for a more local fix by fair
dice roll.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list