1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -std=c++11 -verify %s 2 3 // expected-no-diagnostics 4 5 typedef __typeof(sizeof(int)) size_t; 6 7 void *operator new(size_t size, void *ptr); 8 9 struct B { 10 virtual void foo(); 11 }; 12 13 struct D : public B { fooD14 virtual void foo() override {} 15 }; 16 test_ub()17void test_ub() { 18 // FIXME: Potentially warn because this code is pretty weird. 19 B b; 20 new (&b) D; 21 b.foo(); // no-crash 22 } 23 test_non_ub()24void test_non_ub() { 25 char c[sizeof(D)]; // Should be enough storage. 26 new (c) D; 27 ((B *)c)->foo(); // no-crash 28 } 29