void* realloc (void*, size_t);
}
+namespace std {
+
+#if __cplusplus >= 201103L
+enum class byte: unsigned char { };
+#else
+typedef unsigned char byte;
+#endif
+}
+
/* Ordinary bzcopy and bzero aren't recognized as special. */
#define bcopy __builtin_bcopy
#define bzero __builtin_bzero
struct HasDefault { char a[4]; HasDefault (); };
void test (HasDefault *p, const HasDefault &x,
- void *q, const unsigned char *s, const int ia[])
+ void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (bcopy, (q, p, n));
T (bcopy, (s, p, sizeof *p));
T (bcopy, (s, p, n));
+ T (bcopy, (b, p, n));
T (memcpy, (p, q, sizeof *p));
T (memcpy, (p, q, n));
T (memcpy, (p, s, sizeof *p));
T (memcpy, (p, s, n));
+ T (memcpy, (p, b, n));
T (memmove, (p, q, sizeof *p));
T (memmove, (p, q, n));
T (memmove, (p, s, sizeof *p));
T (memmove, (p, s, n));
+ T (memmove, (p, b, n));
T (mempcpy, (p, q, sizeof *p));
T (mempcpy, (p, q, n));
T (mempcpy, (p, s, sizeof *p));
T (mempcpy, (p, s, n));
+ T (mempcpy, (p, b, n));
// ...but partial copies are diagnosed.
T (memcpy, (p, &x, 1)); // { dg-warning "writing to an object of a non-trivial type .struct HasDefault. leaves 3 bytes unchanged" } */
};
void test (HasTemplateDefault *p, const HasTemplateDefault &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (bcopy, (&x, p, sizeof *p));
T (bcopy, (q, p, sizeof *p));
T (bcopy, (s, p, sizeof *p));
+ T (bcopy, (b, p, sizeof *p));
T (bcopy, (ia, p, sizeof *p)); // { dg-warning "bcopy" }
T (memcpy, (p, &x, sizeof *p));
T (memcpy, (p, q, sizeof *p));
T (memcpy, (p, s, sizeof *p));
+ T (memcpy, (p, b, sizeof *p));
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memmove, (p, &x, sizeof *p));
T (memmove, (p, q, sizeof *p));
T (memmove, (p, s, sizeof *p));
+ T (memmove, (p, b, sizeof *p));
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (mempcpy, (p, &x, sizeof *p));
T (mempcpy, (p, q, sizeof *p));
T (mempcpy, (p, s, sizeof *p));
+ T (mempcpy, (p, b, sizeof *p));
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
// Reallocating is the same as calling memcpy.
struct HasCopy { int i; HasCopy (const HasCopy&); };
void test (HasCopy *p, const HasCopy &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (bcopy, (&x, p, sizeof *p)); // { dg-warning "bcopy" }
T (bcopy, (q, p, sizeof *p)); // { dg-warning "bcopy" }
T (bcopy, (s, p, sizeof *p)); // { dg-warning "bcopy" }
+ T (bcopy, (b, p, sizeof *p)); // { dg-warning "bcopy" }
T (bcopy, (ia, p, sizeof *p)); // { dg-warning "bcopy" }
T (memcpy, (p, &x, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, q, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memmove, (p, &x, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (mempcpy, (p, &x, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
// Reallocating is the same as calling memcpy.
};
void test (HasPrivateCopy *p, const HasPrivateCopy &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, sizeof *p)); // { dg-warning ".void\\* memcpy(\[^\n\r\]*). writing to an object of non-trivially copyable type .struct HasPrivateCopy.; use copy-assignment instead" }
T (memcpy, (p, q, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memmove, (p, &x, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (mempcpy, (p, &x, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
// Reallocating is the same as calling memcpy.
struct HasDtor { int i; ~HasDtor (); };
void test (HasDtor *p, const HasDtor &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, q, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memmove, (p, &x, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (mempcpy, (p, &x, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
// Reallocating is the same as calling memcpy.
};
void test (HasDeletedDtor *p, const HasDeletedDtor &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, sizeof *p));
T (memcpy, (p, q, sizeof *p));
T (memcpy, (p, s, sizeof *p));
+ T (memcpy, (p, b, sizeof *p));
T (memcpy, (p, ia, sizeof *p));
T (memmove, (p, &x, sizeof *p));
T (memmove, (p, q, sizeof *p));
T (memmove, (p, s, sizeof *p));
+ T (memmove, (p, b, sizeof *p));
T (memmove, (p, ia, sizeof *p));
T (mempcpy, (p, &x, sizeof *p));
T (mempcpy, (p, q, sizeof *p));
T (mempcpy, (p, s, sizeof *p));
+ T (mempcpy, (p, b, sizeof *p));
T (mempcpy, (p, ia, sizeof *p));
// Reallocating is diagnosed.
};
void test (HasPrivateDtor *p, const HasPrivateDtor &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, sizeof *p)); // { dg-warning "writing to an object of non-trivially copyable type .struct HasPrivateDtor.; use copy-assignment or copy-initialization instead" }
T (memcpy, (p, q, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memmove, (p, &x, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (mempcpy, (p, &x, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
// Reallocating is diagnosed.
struct HasCopyAssign { void operator= (HasCopyAssign&); };
void test (HasCopyAssign *p, const HasCopyAssign &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, q, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memmove, (p, &x, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (mempcpy, (p, &x, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
// Reallocating is the same as calling memcpy.
};
void test (HasMoveAssign *p, const HasMoveAssign &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, q, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memmove, (p, &x, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (mempcpy, (p, &x, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
// Reallocating is the same as calling memcpy.
};
void test (TrivialCopyHasMoveAssign *p, const TrivialCopyHasMoveAssign &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, q, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memmove, (p, &x, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (mempcpy, (p, &x, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
// Reallocating is the same as calling memcpy.
void test (TrivialMoveNontrivialCopyAssign *p,
const TrivialMoveNontrivialCopyAssign &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, q, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memmove, (p, &x, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (mempcpy, (p, &x, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
// Reallocating is the same as calling memcpy.
};
void test (TrivialAssignRefOverload *p, const TrivialAssignRefOverload &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, sizeof *p));
T (memcpy, (p, q, sizeof *p));
T (memcpy, (p, s, sizeof *p));
+ T (memcpy, (p, b, sizeof *p));
T (memcpy, (p, ia, sizeof *p));
T (memmove, (p, &x, sizeof *p));
T (memmove, (p, q, sizeof *p));
T (memmove, (p, s, sizeof *p));
+ T (memmove, (p, b, sizeof *p));
T (memmove, (p, ia, sizeof *p));
T (mempcpy, (p, &x, sizeof *p));
T (mempcpy, (p, q, sizeof *p));
T (mempcpy, (p, s, sizeof *p));
+ T (mempcpy, (p, b, sizeof *p));
T (mempcpy, (p, ia, sizeof *p));
T (q = realloc, (p, 1));
void test (TrivialAssignCstRefOverload *p,
const TrivialAssignCstRefOverload &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, sizeof *p));
T (memcpy, (p, q, sizeof *p));
T (memcpy, (p, s, sizeof *p));
+ T (memcpy, (p, b, sizeof *p));
T (memcpy, (p, ia, sizeof *p));
T (memmove, (p, &x, sizeof *p));
T (memmove, (p, q, sizeof *p));
T (memmove, (p, s, sizeof *p));
+ T (memmove, (p, b, sizeof *p));
T (memmove, (p, ia, sizeof *p));
T (mempcpy, (p, &x, sizeof *p));
T (mempcpy, (p, q, sizeof *p));
T (mempcpy, (p, s, sizeof *p));
+ T (mempcpy, (p, b, sizeof *p));
T (mempcpy, (p, ia, sizeof *p));
T (q = realloc, (p, 1));
void test (TrivialRefHasVolRefAssign *p,
const TrivialRefHasVolRefAssign &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, q, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memmove, (p, &x, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (mempcpy, (p, &x, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
// Reallocating is the same as calling memcpy.
};
void test (HasVolRefAssign *p, const HasVolRefAssign &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, q, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memmove, (p, &x, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (mempcpy, (p, &x, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
// Reallocating is the same as calling memcpy.
struct HasVirtuals { int i; virtual void foo (); };
void test (HasVirtuals *p, const HasVirtuals &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, q, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memmove, (p, &x, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (mempcpy, (p, &x, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
// Reallocating is the same as calling memcpy.
struct HasConstData { const char a[4]; };
void test (HasConstData *p, const HasConstData &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
// { dg-warning "writing to an object of type .struct HasConstData. with no trivial copy-assignment" "c++ 98" { target { c++98_only } } .-1 }
T (memcpy, (p, q, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memmove, (p, &x, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (mempcpy, (p, &x, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
// Reallocating is not diagnosed except in C++ 98 due to a bug.
struct HasReference { int &ci; };
void test (HasReference *p, const HasReference &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, q, n)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, n)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, n)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, n)); // { dg-warning "memcpy" }
T (memmove, (p, &x, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (mempcpy, (p, &x, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
// Reallocating is not diagnosed because a type with a reference
struct HasMemDataPtr { int HasMemDataPtr::*p; };
void test (HasMemDataPtr *p, const HasMemDataPtr &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, q, n));
T (memcpy, (p, s, sizeof *p));
T (memcpy, (p, s, n));
+ T (memcpy, (p, b, sizeof *p));
+ T (memcpy, (p, b, n));
T (memcpy, (p, ia, sizeof *p));
T (memcpy, (p, ia, n));
T (memmove, (p, &x, sizeof *p));
T (memmove, (p, q, sizeof *p));
T (memmove, (p, s, sizeof *p));
+ T (memmove, (p, b, sizeof *p));
T (memmove, (p, ia, sizeof *p));
T (mempcpy, (p, &x, sizeof *p));
T (mempcpy, (p, q, sizeof *p));
T (mempcpy, (p, s, sizeof *p));
+ T (mempcpy, (p, b, sizeof *p));
T (mempcpy, (p, ia, sizeof *p));
// Reallocating is the same as calling memcpy.
struct HasSomePrivateData { char a[2]; private: char b[2]; };
void test (HasSomePrivateData *p, const HasSomePrivateData &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, n));
T (memcpy, (p, q, sizeof *p));
T (memcpy, (p, s, sizeof *p));
+ T (memcpy, (p, b, sizeof *p));
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, n)); // { dg-warning "memcpy" }
T (memmove, (p, &x, n));
T (memmove, (p, q, sizeof *p));
T (memmove, (p, s, sizeof *p));
+ T (memmove, (p, b, sizeof *p));
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, n)); // { dg-warning "memmove" }
T (mempcpy, (p, q, n));
T (mempcpy, (p, s, sizeof *p));
T (mempcpy, (p, s, n));
+ T (mempcpy, (p, b, sizeof *p));
+ T (mempcpy, (p, b, n));
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, n)); // { dg-warning "mempcpy" }
struct HasSomeProtectedData { char a[2]; protected: char b[2]; };
void test (HasSomeProtectedData *p, const HasSomeProtectedData &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, n));
T (memcpy, (p, q, sizeof *p));
T (memcpy, (p, s, sizeof *p));
+ T (memcpy, (p, b, sizeof *p));
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, n)); // { dg-warning "memcpy" }
T (memmove, (p, &x, n));
T (memmove, (p, q, sizeof *p));
T (memmove, (p, s, sizeof *p));
+ T (memmove, (p, b, sizeof *p));
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, n)); // { dg-warning "memmove" }
T (mempcpy, (p, q, n));
T (mempcpy, (p, s, sizeof *p));
T (mempcpy, (p, s, n));
+ T (mempcpy, (p, b, sizeof *p));
+ T (mempcpy, (p, b, n));
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, n)); // { dg-warning "mempcpy" }
struct HasAllPrivateData { private: char a[4]; };
void test (HasAllPrivateData *p, const HasAllPrivateData &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, n));
T (memcpy, (p, q, sizeof *p));
T (memcpy, (p, s, sizeof *p));
+ T (memcpy, (p, b, sizeof *p));
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, n)); // { dg-warning "memcpy" }
T (memmove, (p, &x, n));
T (memmove, (p, q, sizeof *p));
T (memmove, (p, s, sizeof *p));
+ T (memmove, (p, b, sizeof *p));
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, n)); // { dg-warning "memmove" }
T (mempcpy, (p, q, n));
T (mempcpy, (p, s, sizeof *p));
T (mempcpy, (p, s, n));
+ T (mempcpy, (p, b, sizeof *p));
+ T (mempcpy, (p, b, n));
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, n)); // { dg-warning "mempcpy" }
struct HasAllProtectedData { protected: char a[4]; };
void test (HasAllProtectedData *p, const HasAllProtectedData &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, &x, n));
T (memcpy, (p, q, sizeof *p));
T (memcpy, (p, s, sizeof *p));
+ T (memcpy, (p, b, sizeof *p));
T (memcpy, (p, ia, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, ia, n)); // { dg-warning "memcpy" }
T (memmove, (p, &x, n));
T (memmove, (p, q, sizeof *p));
T (memmove, (p, s, sizeof *p));
+ T (memmove, (p, b, sizeof *p));
T (memmove, (p, ia, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, ia, n)); // { dg-warning "memmove" }
T (mempcpy, (p, q, n));
T (mempcpy, (p, s, sizeof *p));
T (mempcpy, (p, s, n));
+ T (mempcpy, (p, b, sizeof *p));
+ T (mempcpy, (p, b, n));
T (mempcpy, (p, ia, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, ia, n)); // { dg-warning "mempcpy" }
};
void test (HasDefaultPrivateAssign *p, const HasDefaultPrivateAssign &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, q, n)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, n)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, n)); // { dg-warning "memcpy" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, n)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, n)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, n)); // { dg-warning "memmove" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, n)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, n)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, n)); // { dg-warning "mempcpy" }
// Same for partial copies are diagnosed.
T (memcpy, (p, &x, 1)); // { dg-warning "writing to an object of type .struct HasDefaultPrivateAssign. with (deleted|no trivial) copy-assignment" } */
};
void test (HasDefaultDeletedAssign *p, const HasDefaultDeletedAssign &x,
- const void *q, const unsigned char *s, const int ia[])
+ const void *q, const unsigned char *s, const std::byte *b,
+ const int ia[])
{
const int i = *ia;
const size_t n = *ia;
T (memcpy, (p, q, n)); // { dg-warning "memcpy" }
T (memcpy, (p, s, sizeof *p)); // { dg-warning "memcpy" }
T (memcpy, (p, s, n)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, sizeof *p)); // { dg-warning "memcpy" }
+ T (memcpy, (p, b, n)); // { dg-warning "memcpy" }
T (memmove, (p, q, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, q, n)); // { dg-warning "memmove" }
T (memmove, (p, s, sizeof *p)); // { dg-warning "memmove" }
T (memmove, (p, s, n)); // { dg-warning "memmove" }
+ T (memmove, (p, b, sizeof *p)); // { dg-warning "memmove" }
+ T (memmove, (p, b, n)); // { dg-warning "memmove" }
T (mempcpy, (p, q, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, q, n)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, sizeof *p)); // { dg-warning "mempcpy" }
T (mempcpy, (p, s, n)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, sizeof *p)); // { dg-warning "mempcpy" }
+ T (mempcpy, (p, b, n)); // { dg-warning "mempcpy" }
// Same for partial copies are diagnosed.
T (memcpy, (p, &x, 1)); // { dg-warning "writing to an object of type .struct HasDefaultDeletedAssign. with (deleted|no trivial) copy-assignment" } */