Possible error in EmitCXXNewAllocSize

I was looking through the code for this function, and on line 533,
where you check whether an overflow occurred, you say
      DidOverflow = CGF.Builder.CreateAnd(DidOverflow, AddDidOverflow);
Shouldn't this be an OR? Doesn't the error occur if either the
multiplication or the addition overflowed?


You're right; testcase demonstrating the overflow:
struct A { char x[1<<16]; ~A(); };
A* f() { int x = 1<<16; return new A[x]; };

Run this through "clang -x c++ - -o - -S -m32 -emit-llvm -O2", and you
get "tail call noalias i8* @_Znaj(i32 4)".


Fixed in r129231.