[llvm-bugs] [Bug 52345] New: sporadic crashes while compiling min/max implementations
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 29 04:06:54 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=52345
Bug ID: 52345
Summary: sporadic crashes while compiling min/max
implementations
Product: clang
Version: 12.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: janezz55 at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
Interestingly, clang++ won't crash every time, but only now and then:
clang++ -std=c++20 dpp.cpp -o dpp
code is here:
https://github.com/user1095108/dpp
the code that appears to cause the crash:
template <typename U>
constexpr static auto bit_size_v(CHAR_BIT * sizeof(U));
template <typename U>
constexpr static auto is_integral_v(
std::is_integral_v<U> || std::is_same_v<U, DPP_INT128T>
);
template <typename U>
constexpr static auto is_signed_v(
std::is_signed_v<U> || std::is_same_v<U, DPP_INT128T>
);
template <typename U>
consteval auto min() noexcept
{
if constexpr(detail::is_signed_v<U>)
{
return U(U(1) << (detail::bit_size_v<U> - 1));
}
else
{
return U{};
}
}
template <typename U>
consteval auto max() noexcept
{
if constexpr(detail::is_signed_v<U>)
{
return -U(min<U>() + U(1));
}
else
{
return ~U();
}
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211029/aeaeb257/attachment.html>
More information about the llvm-bugs
mailing list