Skip to content

Commit

Permalink
[libc][NFC] add an atof test for a fuzz failure
Browse files Browse the repository at this point in the history
The differential fuzzer found that glibc and our libc disagree on the
result for "0x30000002222225p-1077", with ours being rounded up and
theirs rounded down. Ours is more correct for the nearest rounding mode,
so only a test is added.

Reviewed By: lntue, sivachandra

Differential Revision: https://reviews.llvm.org/D145821
  • Loading branch information
michaelrj-google committed Mar 14, 2023
1 parent 1b49015 commit 7aec387
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libc/test/src/stdlib/strtod_test.cpp
Expand Up @@ -191,4 +191,9 @@ TEST_F(LlvmLibcStrToDTest, FuzzFailures) {
"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN?",
0, uint64_t(0));
run_test("0x.666E40", 9, uint64_t(0x3fd99b9000000000));

// glibc version 2.36 and higher (not tested with lower versions) disagrees
// with this result, but ours is correct for the nearest rounding mode. See
// this bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30220
run_test("0x30000002222225p-1077", 22, uint64_t(0x0006000000444445), ERANGE);
}

0 comments on commit 7aec387

Please sign in to comment.