базового класса зовется неявно, так ?
                  
                  
                  https://godbolt.org/z/1rd6YPP7r
                  
                  
                  
                  
                  
                  В случае с clang, явный вызов конструктора базового класса генерирует разный код.
                  
                  
                  Зачем-то вставляет memset, который похоже, может портить данные.
                  
                  
                  
                  
                  
                  class Derived : public Base
                  
                  
                  {
                  
                  
                  public:
                  
                  
                    Derived()
                  
                  
                      : Base() // asm: call memset; Base::Base()
                  
                  
                    {}
                  
                  
                  };
                  
                  
                
гцц вроде так же делает, только у него вместо memset mov DWORD PTR [rax], 0
Вот тут есть вроде ответ https://stackoverflow.com/questions/13576055/how-is-default-different-from-for-default-constructor-and-destructor To value-initialize an object of type T means: — if T is a (possibly cv-qualified) class type (Clause 9) with a user-provided constructor (12.1), then the default constructor for T is called (and the initialization is ill-formed if T has no accessible default constructor); — if T is a (possibly cv-qualified) non-union class type without a user-provided constructor, then the object is zero-initialized and, if T’s implicitly-declared default constructor is non-trivial, that constructor is called
Обсуждают сегодня