https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97632

            Bug ID: 97632
           Summary: unhelpful -Winit-list-lifetime warning for
                    default-initialized object in unevaluated context
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

// { dg-options "-std=gnu++20" }
#include <initializer_list>

  template<typename _Tp>
    concept default_initializable =
      requires
      {
        _Tp{};
        (void) ::new _Tp;
      };

static_assert( default_initializable<std::initializer_list<int>> );

GCC warns about this code:

warning: 'new' of 'initializer_list' does not extend the lifetime of the
underlying array [-Winit-list-lifetime]

I'm not sure this is very useful. Firstly, it's an unevaluated operand, so
there's no lifetime of anything here. Secondly, it's being constructed without
a new-initializer, so it's just an empty std::initializer_list, so there's no
underlying array.

Reply via email to