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

            Bug ID: 124344
           Summary: Default member initializer instantiation time
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antoshkka at gmail dot com
  Target Milestone: ---

Consider the following example:


class Some0;

template <class T>
T* assert_complete() {
    static_assert(sizeof(T) > 0);
    return nullptr;
}

struct MyClass {
    MyClass();

private:
    Some0* impl_ = assert_complete<Some0>();
};

MyClass g;


At the moment the static_assert with GCC-16 fails. Other compilers do allow the
above code to compile.

Looks like a more lazy evaluation of default member initializer could improve 
GCC compile times for cases where the default member initializer is used only
in .cpp file and the header file is used in many translation units.


Godbolt playground: https://godbolt.org/z/ecnKr6eK5

Reply via email to