...
| Code Block | ||||
|---|---|---|---|---|
| ||||
#include <cstdlib>
struct S {
S();
void f();
};
void fg() {
S *s = static_cast<S *>(std::malloc(sizeof(S)));
s->f();
std::free(s);
} |
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
#include <cstdlib>
#include <new>
struct S {
S();
void f();
};
void fg() {
void *ptr = std::malloc(sizeof(S));
S *s = new (ptr) S;
s->f();
s->~S();
std::free(sptr);
} |
Noncompliant Code Example
...