shorts;// expected-note {{'s' declared without an initial value}}
long*lp=::new(&s)long;// expected-warning{{Storage provided to placement new is only 2 bytes, whereas the allocated type requires 8 bytes}} expected-note 3 {{}}
(void)lp;
}
namespacetestArrayNew{
voidf(){
shorts;// expected-note {{'s' declared without an initial value}}
char*buf=::new(&s)char[8];// expected-warning{{Storage provided to placement new is only 2 bytes, whereas the allocated type requires 8 bytes}} expected-note 3 {{}}
(void)buf;
}
}// namespace testArrayNew
namespacetestBufferInOtherFun{
voidf(void*place){
long*lp=::new(place)long;// expected-warning{{Storage provided to placement new is only 2 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}
(void)lp;
}
voidg(){
shortbuf;// expected-note {{'buf' declared without an initial value}}
f(&buf);// expected-note 2 {{}}
}
}// namespace testBufferInOtherFun
namespacetestArrayBuffer{
voidf(void*place){
long*lp=::new(place)long;// expected-warning{{Storage provided to placement new is only 2 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}
gptr=&gs;// expected-note {{Value assigned to 'gptr'}}
}
voidg(){
f();// expected-note 2 {{}}
long*lp=::new(gptr)long;// expected-warning{{Storage provided to placement new is only 2 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}
(void)lp;
}
}// namespace testGlobalPtrAsPlace
namespacetestRvalue{
shortgs;
void*f(){
return&gs;
}
voidg(){
long*lp=::new(f())long;// expected-warning{{Storage provided to placement new is only 2 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}
long*lp=::new(st)long;// expected-warning{{Storage provided to placement new is only 3 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}
long*lp=::new(buf+2)long;// expected-warning{{Storage provided to placement new is only 4 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}
long*lp=::new(buf+3)long;// expected-warning{{Storage provided to placement new is only 0 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}
long*lp=::new(buf+4)long;// expected-warning{{Storage provided to placement new is only -4 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}
long*lp=::new(buf)long;// expected-warning{{Storage provided to placement new is only 2 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}
long*lp=::new(buf)long;// expected-warning{{Storage provided to placement new is only 6 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}
long*lp=::new(buf+1)long;// expected-warning{{Storage provided to placement new is only 3 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}
long*lp=::new(&buf[1][1])long;// expected-warning{{Storage provided to placement new is only 2 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}
(void)lp;
}
}// namespace testMultiDimensionalArray3
namespacetestHierarchy{
structBase{
chara[2];
};
structDerived:Base{
charx[2];
inty;
};
voidf(){
Baseb;// expected-note {{'b' initialized here}}
Derived*dp=::new(&b)Derived;// expected-warning{{Storage provided to placement new is only 2 bytes, whereas the allocated type requires 8 bytes}} expected-note 1 {{}}