From 26fe6fc1c21e1e37ad5cd0905238a4573d87b027 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 8 Jul 2024 14:19:51 -0600 Subject: [PATCH] Fix UB when using `-ffast-math` --- .clang-tidy | 1 - src/Raytracer.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 68bf07a..632dd91 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,4 @@ Checks: > - -*, bugprone-*, clang-analyzer-*, concurrency-*, diff --git a/src/Raytracer.cpp b/src/Raytracer.cpp index 1c92977..244e11f 100644 --- a/src/Raytracer.cpp +++ b/src/Raytracer.cpp @@ -64,7 +64,7 @@ namespace { if (depth == 0) return sf::Vector3f(); - if (const auto maybe_hit = hit(scene, ray, 0.001f, std::numeric_limits::infinity())) { + if (const auto maybe_hit = hit(scene, ray, 0.001f, std::numeric_limits::max())) { if (const auto result = scatter(*maybe_hit->material, ray, *maybe_hit)) { const auto& [attenuation, scattered] = *result; return attenuation.cwiseMul(trace_ray(scene, scattered, depth - 1));