[cfe-dev] C++11 doing double zero initialization?

Robinson, Paul via cfe-dev cfe-dev at lists.llvm.org
Tue Dec 20 16:39:50 PST 2016


Consider the following source:

  struct C { C() = default; C(const C&); int n; };
  const C c1 = C();

then run it through `clang -emit-llvm -std=c++11`, 
and I see the following relevant bits:

  %struct.C = type { i32 }
  @_ZL2c1 = internal global %struct.C zeroinitializer, align 4
  define internal void @__cxx_global_var_init() {{.*}} {
  entry:
    call void @llvm.memset.p0i8.i64(i8* bitcast (%struct.C* @_ZL2c1 to i8*),
      i8 0, i64 4, i32 4, i1 false)
    ret void
  }


The question is: Why the memset?  Doesn't 'zeroinitializer'
do the exact same thing?  I don't see the memset with C++03.

Thanks,
--paulr




More information about the cfe-dev mailing list