https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84886
Bug ID: 84886 Summary: Add static checking to library components Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- There are several places where we could diagnose undefined behaviour: #include <array> const std::array<int, 0> a0{}; int i0 = a0[0]; // undefined const std::array<int, 1> a1{}; int i1 = a1[1]; // undefined #include <string_view> const std::string_view s; char c0 = s[0]; // undefined char c1 = s.front(); // undefined // not even in constant expressions: constexpr std::string_view s1("a"); constexpr char c2 = s1[1]; // undefined #include <atomic> int main() { std::atomic<int> a{}; a.load(std::memory_order_release); // undefined } These can be turned into compile-time errors: https://gcc.gnu.org/ml/libstdc++/2018-03/msg00031.html https://gcc.gnu.org/ml/libstdc++/2018-03/msg00032.html For std::array<N, 0> we need to ensure explicit instantiation works, without operator[] causing errors.