https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98216
Bug ID: 98216 Summary: [C++20] std::array<double, N> template parameter error with negative values Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: emmanuel.le-tr...@cnrs-orleans.fr Target Milestone: --- Sorry for the bad title, I can't figure out how to summarize this: #include <array> #include <cassert> using an_array = std::array <double, 1>; constexpr auto add_array (an_array a, an_array const& b) { a[0] += b[0]; return a; } template <an_array A> struct wrapper { static constexpr auto arr = A; }; template <an_array A1 ,an_array A2 > auto add (wrapper <A1> const&, wrapper <A2> const&) { return wrapper <add_array (A1, A2)> {}; } constexpr auto ONE = an_array {{ 1. }}; constexpr auto MINUS_ONE = an_array {{ -1. }}; constexpr auto MINUS_TWO = an_array {{ -2. }}; int main () { auto a = wrapper <MINUS_TWO> {}; auto b = wrapper <ONE> {}; auto c = add (a, b); assert (c.arr == MINUS_TWO); // <- should fail assert (c.arr == MINUS_ONE); // <- should pass } Compiled with version 11.0.0 20201209, the first assertion passes and the second fails. It should be the opposite. FWIW, if you replace double by float, it works as intended.